https://www.colorless-sight.jp:443/wiki/?ProjectEular%2FProblem12
-- Problem 12 module Main (main) where import qualified Common as C (divisors) main :: IO () main = print $ problem12 problem12 :: (Integral a) => (a, a) problem12 = calc_iter (1, (triangle 1)) 500 calc_iter :: (Integral a) => (a, a) -> Int -> (a, a) calc_iter (nth,tri) max | count_divisors tri > max = (nth,tri) | otherwise = calc_iter (nth+1, tri+(nth+1)) max count_divisors :: (Integral a) => a -> Int count_divisors num = length $ C.divisors num triangle :: (Integral a) => a -> a triangle num = sum [1..num] |
最新の20件2023-08-12
2022-12-28
2017-08-15
2014-01-31
2014-01-29
2013-06-04
2012-11-23
2010-08-01
2010-07-24
Tweet
|