haskell: add p1, p2

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-10-26 12:49:33 +05:30
parent fcce234a10
commit 6c89f18e9d
3 changed files with 15 additions and 0 deletions

View File

@@ -1 +1,4 @@
module Lib where
fib :: [ Integer ]
fib = 1 : 2 : zipWith (+) fib (tail fib)

5
haskell/p1.hs Normal file
View File

@@ -0,0 +1,5 @@
main :: IO ()
main = putStr $ show solve
solve :: Integer
solve = sum [ x | x <- [0..999], mod x 3 == 0 || mod x 5 == 0 ]

7
haskell/p2.hs Normal file
View File

@@ -0,0 +1,7 @@
import Lib (fib)
main :: IO ()
main = putStr $ show solve
solve :: Integer
solve = sum $ filter even $ takeWhile (<= 4000000) fib