Life Goes On

まあまあだけど楽しんでる方です

2008-04-05から1日間の記事一覧

30問目

http://projecteuler.net/index.php?section=problems&id=30 各桁の数字の5乗の和が元の数字と等しくなるような数の和を求める。 import Data.Char main = print $ sum $ euler030 5 euler030 :: Int -> [Int] euler030 n = filter judge [2..9^(n+1)] wher…

28問目

http://projecteuler.net/index.php?section=problems&id=28 1辺が1001の正方形に螺旋状に並んだ数字のうち、対角線にあるものの和を求める。 main = print $ euler028 1001 euler028 :: Int -> Int euler028 n = sum $ map calc [1,3..n] calc :: Int -> I…

29問目

http://projecteuler.net/index.php?section=problems&id=29 2以上100以下のa,bに対してabがいくつあるか、重複するものを除いて答える。 import Data.List main = print $ euler029 100 euler029 :: Integer -> Int euler029 m = length $ nub $ [a ^ b | a …

27問目

http://projecteuler.net/index.php?section=problems&id=27 n2 + an + b, |a| で表される数列があったとき、連続する素数の数が最大となるようなa,bの積を求める。 n=0,1のときの条件からbが素数、a>-bだと分かるのでそれで範囲を狭めて、あとはひたすら調…