diff options
Diffstat (limited to 'haskell/wip')
| -rw-r--r-- | haskell/wip/023-non_abundant_sum.hs | 10 |
1 files changed, 5 insertions, 5 deletions
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 |
