[[ProjectEular]]

 -- 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


トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS