tag:qiita.com,2005:/tags/project_euler/feed Project_Eulerタグが付けられた新着記事 - Qiita QiitaでProject_Eulerタグが付けられた新着記事 2012-09-06T18:27:22+09:00 https://qiita.com/tags/project_euler tag:qiita.com,2005:PublicArticle/8883 2012-09-06T18:27:22+09:00 2012-09-06T18:27:22+09:00 https://qiita.com/myuon_myon/items/e9a1a3c2c5097c72c1e7 Project Euler/problm 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 the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. problem2.hs import Data.List main = print \$ foldl1 (+) \$ filter even \$ takeWhile(&lt;4000000) \$ fibList [2..] fibList::[Int]-&gt;[Integer] fibList = map (\n-&gt;round ((((1+sqrt 5)/2)^n - ((1-sqrt 5)/2)^n)/(sqrt 5))) answer 4613732 myuon_myon tag:qiita.com,2005:PublicArticle/8794 2012-09-05T12:52:17+09:00 2012-09-05T12:52:17+09:00 https://qiita.com/myuon_myon/items/cb913f54eb9e8905555a Project Euler/problem 1 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. problem1.hs main = print \$ sum [x|x&lt;-[1..999], x `mod` 3 == 0 || x `mod` 5 ==0] answer 233168 myuon_myon