12 lines
448 B
Haskell
12 lines
448 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?
|
||
|
||
factorial :: (Integral a) => a -> a
|
||
factorial 0 = 1
|
||
factorial n = n * factorial (n - 1)
|
||
|
||
main = do
|
||
let result = factorial 40 `div` factorial 20 ^ 2
|
||
putStrLn $ "Project Euler, Problem 15\n"
|
||
++ "Answer: " ++ show result
|