Add basic Project Euler solutions
This commit is contained in:
10
project-euler-haskell/problem1.hs
Normal file
10
project-euler-haskell/problem1.hs
Normal file
@@ -0,0 +1,10 @@
|
||||
fn :: Integer -> Integer
|
||||
fn n | n < 3 = 0
|
||||
| n == 3 = 3
|
||||
| n `rem` 3 == 0 || n `rem` 5 == 0 = n + fn (n-1)
|
||||
| otherwise = fn (n-1)
|
||||
main = do
|
||||
putStrLn "The sum of the multiples of 3 and 5 from 1 to 1000 is:"
|
||||
print (fn 1000)
|
||||
|
||||
-- filter (\n -> n \`rem\` 3 == 0)
|
||||
Reference in New Issue
Block a user