haskell: add [p12, p17]
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
10
haskell/p12.hs
Normal file
10
haskell/p12.hs
Normal file
@@ -0,0 +1,10 @@
|
||||
import Lib (factors)
|
||||
|
||||
main :: IO ()
|
||||
main = putStr $ show $ solve 500
|
||||
|
||||
solve :: Int -> Integer
|
||||
solve n = head [tn | i <- [1 ..], let tn = triangleNumber i, (length . factors) tn > n]
|
||||
|
||||
triangleNumber :: Int -> Integer
|
||||
triangleNumber n = toInteger $ div (n * (n + 1)) 2
|
Reference in New Issue
Block a user