https://www.colorless-sight.jp:443/wiki/?ProjectEular%2FProblem21
-- Problem 21 module Main (main) where import qualified List as L (nub) import qualified Common as C (proper_divisors) main :: IO () main = print $ problem21 problem21 :: Int problem21 = sum $ map sum_pair $ amicable_pairs 9999 where sum_pair (x,y) = x + y amicable_pairs :: Int -> [(Int,Int)] amicable_pairs max_n = [ (n, d n) | n <- [2..max_n], n < d n, n == d (d n) ] d :: Int -> Int d n = sum $ C.proper_divisors n |
最新の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
|