Project Euler

Problem 16

2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number 2^1000? 訳 2^15 = 32768 であり,その各桁の数の和は 3 + 2 + 7 + 6 + 8 = 26 である.では,2^1000の各桁の和を求めよ. Haskell シンプ…

Problem 15

Starting in the top left corner of a grid, there are 6 routes (without backtracking) to the bottom right corner.(figure is omitted)How many routes are there through a grid? 訳 の格子の左上隅からスタートして,右下隅に,逆戻りしないで到着す…

Problem 14 (その3:答えはでた)

なぜスタックがあふれるのか.答えは自明で何でも溜め込むからなんですよね.1000000までの各整数に対してコラッツ列の長さを求めて,最大のものを求めると1000000個の要素のリストを扱わないといけないのは当たり前で,当然あふれても仕方がないです.キャ…

Problem 14 (その2:未解決)

わからない・・・どうやっても1000000で処理すると *** Exception: stack overflow がでるか,異常な時間がかかってやってられない・・・むむーー.前のコード {- Project Euler Problem 14 e14.hs -} collatz::Integer -> [Integer] collatz n | n == 1 = […

Problem 14

The following iterative sequence is defined for the set of positive integers:n n/2 (n is even) n 3n + 1 (n is odd)Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1It can be seen that th…

Problem 13

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 7432498619952474105947423330951305812372661730962…

Problem 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, ...Let us list the factors o…

Problem 11

In the grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88…

Problem 10

素数関係なので着手. The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million. 訳 10未満の素数の和は2 + 3 + 5 + 7 = 17.2,000,000未満のすべての素数の和を求めよ. [Haskell] 前に考えたものをそのま…

Problem 9

A Pythagorean triplet is a set of three natural numbers, [tex:$a 訳 ピタゴラス数とは自然数の三つ組で[tex:$a [Haskell] {- Project Euler Problem 9 e9.hs -} line:: Int -> [(Int,Int)] line k = [(i,k-i) | i<-[0..k], i*k == 500, i>k-i ] lattice:…

Problem 8

Find the greatest product of five consecutive digits in the 1000-digit number.73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698…

Problem 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? 訳 最初の六つの素数,2,3,5,7,11,13を列挙することで,6番目の素数が13であることがわかる.10001番目の素…

Problem 6

The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 55^2 = 3025Hence the difference between the sum of the squares of the…

Problem 5

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 number that is evenly divisible by all of the numbers from 1 to 20? 訳 2520は,1から10までのそれぞれの数で割り切…

素因数分解

コメント欄でご指摘いただいたことを考えてみます.素因数分解をする際に素数の列として,エラトステネスの篩ではなく, primes = 2:3:([6,12..] >>= (\x->[x-1,x+1] ) を使うというテクニック.6の倍数の「前後」を「素数のタネ」として使うということです…

Problem 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 numbers. 訳 「回文数」とは右から読んでも…

Problem 3

一週間,追記できなかったので,2008-03-23 - dachs_hippoの日記を仕切りなおし. 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の…

Problem 3

日が開いたので2008-03-29 - dachs_hippoの日記へ 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の最大の素因数は何か? 単純にはで…

Problem 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, ...Find the sum of all the even-valued terms in the sequence whi…

Problem 1

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 these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. 訳. 10未満で3と5の倍数である自然数をあげると,3,5,6…