2011-04-01から1ヶ月間の記事一覧

Project Euler No.12

Project Euler続き。12問目。 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …

Project Euler No.11

Project Eulerの11問目。 In the 2020 grid below, four numbers along a diagonal line have been marked in red.(数表省略)The product of these numbers is 26 × 63 × 78 × 14 = 1788696.What is the greatest product of four adjacent numbers in any d…

Project Euler No.10

さてさて第10問目のProject Euler。 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million.10未満の素数の和は17である。2百万未満の全素数の和はいくつか。 Matlabにはprimes関数があるので楽勝です。…

Project Euler No.9

次々行くよ。Project Eulerの9問目。 A Pythagorean triplet is a set of three natural numbers, a b c, for which,a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find…

Project Euler No.8

引き続きProject Eulerの8問目。 Find the greatest product of five consecutive digits in the 1000-digit number.73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586156078911294949545950173…

Project Euler No.7

MatlabでProject Eulerを解く第7問。 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number?最初の6つの素数を並べると2、3、5、7、11、13となる。6番目の素数は13だと…

Project Euler No.6

Project EulerをMatlab/Octaveで解く6問目。いったい何問あるんだ、これ? The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 …

Project Euler No.5

引き続きProject EulerをMatlab/Octaveで解いてます。 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the number…

Project Euler No.4

Project Eulerの第4問は「数字の回文」。 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.Find the largest palindrome made from the product of two 3-digit nu…

Project Euler No.3

Project Eulerの問題をMatlab/Octaveで解いてみる3問目。 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?13195の素因数は5、7、13、29である。600851475143の素因数のうち最大のものは何…

Project Euler No.2

Project Eulerの問題をMatlabで解いてみる2問目。 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering…

Project Euler No.1

Project Eulerはコンピュータで解くための問題集を公開しているサイトです。その第1問目をMatlabでやってみました。Octaveでも動きます。 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of the…

相互相関と畳み込み

相互相関と畳み込みは処理が似ているので、どちらかを使ってもう一方を計算できないかと考えた。で、Matlabで実験したところ、xcorr(a, b)はconv(a, flipud(b))と同じだということがわかった。convの代わりにFFTを用いて処理してみたが*1、xcorrのほうが若干…