2008-10-27から1日間の記事一覧

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? *Main> sum.map digitToInt.show$2^1000 1366

Problem 15

Starting in the top left corner of a 2x2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20x20 grid? Integerを使えば簡単。 p015 n = product[n+1..2*n]`div`product[1..n]

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 1 It can be seen that t…

Problem 13

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. そのまま。 main =replicateM 100 (liftM read getLine)>>=putStrLn.(take 10).show.sum {-- $ time ./p010.exe < p013.txt 5537376230 ./p010.exe < p013.txt 0.…