2008-09-02から1日間の記事一覧

Project Euler: Problem35

昔の問題のコードを流用してるので、primes の使い方がちょっとおかしいような。"123"から["123","231","312"]を作る部分(begin-end-untilのとこ)は某 id:mallowlabs さんと少し話したのだけど、なんか普通の書き方になった。counter をインクリメントすると…

Project Euler: Problem40

import Data.Char main = print $ summation 1 $ concatMap show [1..] summation n (x:xs) = case n of 1 -> digitToInt x * summation (n+1) xs 10 -> digitToInt x * summation (n+1) xs 100 -> digitToInt x * summation (n+1) xs 1000 -> digitToInt x …