17 lines
497 B
Haskell
17 lines
497 B
Haskell
-- Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner
|
||
-- How many such routes are there through a 20×20 grid?
|
||
|
||
module P015 (p015) where
|
||
|
||
factorial :: Integer -> Integer
|
||
factorial 0 = 1
|
||
factorial n = n * factorial (n - 1)
|
||
|
||
p015 :: IO ()
|
||
p015 = do
|
||
let result = factorial 40 `div` factorial 20 ^ (2 :: Int)
|
||
putStrLn $
|
||
"Project Euler, Problem 15\n"
|
||
++ "Answer: "
|
||
++ show result
|