From 77cf528cf5b14b3beb067f560753b1e5a3960bbd Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 18 Nov 2019 20:49:50 +0100 Subject: problem 23 c --- haskell/wip/023-non_abundant_sum.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'haskell/wip') diff --git a/haskell/wip/023-non_abundant_sum.hs b/haskell/wip/023-non_abundant_sum.hs index d519eb6..9174aef 100644 --- a/haskell/wip/023-non_abundant_sum.hs +++ b/haskell/wip/023-non_abundant_sum.hs @@ -46,12 +46,12 @@ notAbundantSum x abundants = [n | n <- [1..28123], divSum n > n] divSum :: Int -> Int -divSum n = factorise 2 - where factorise d +divSum n = factorize 2 + where factorize d | d > nSqrt = 1 - | rest == 0 && d /= quotient = d + quotient + factorise (d + 1) - | rest == 0 && d == quotient = quotient + factorise (d + 1) - | otherwise = factorise (d + 1) + | rest == 0 && d /= quotient = d + quotient + factorize (d + 1) + | rest == 0 && d == quotient = quotient + factorize (d + 1) + | otherwise = factorize (d + 1) where quotient = n `div` d rest = n `mod` d nSqrt = floor $ sqrt $ fromIntegral n -- cgit