https://www.colorless-sight.jp:443/wiki/?ProjectEular%2FProblem23
-- Problem 23
module Main (main) where
import Array
import qualified Common as C (proper_divisors)
main :: IO ()
main = print $ problem23 28123
problem23 :: Int -> Int
problem23 max_n = sum [ n | n <- [1..max_n], null (abundant_pairs array n) ]
where array = listArray (1,max_n) (map is_abundant [1..max_n])
abundant_pairs :: Array Int Bool -> Int -> [(Int,Int)]
abundant_pairs array n = [ (x,(n-x)) | x <- [1..(div n 2)], array ! x, array ! (n-x) ]
is_abundant :: Int -> Bool
is_abundant n = sum (C.proper_divisors n) > 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
Tweet
|