Ad
Code
Diff
  • def divisors(number):
        dividers = []
        for i in range(1,number+1):
            if(number % i == 0):
                dividers.append(i)
        return dividers
    • module Divisors where
    • divisors :: Integer -> [Integer]
    • divisors n = 1:n:(divisorsAux 2)
    • where
    • divisorsAux k
    • | (fromIntegral k) > sqrt (fromIntegral n) = []
    • | otherwise = if n `mod` k == 0
    • then if n`div`k ==k
    • then k:(divisorsAux (k+1))
    • else k:(n`div`k):(divisorsAux (k+1))
    • else divisorsAux (k+1)
    • def divisors(number):
    • dividers = []
    • for i in range(1,number+1):
    • if(number % i == 0):
    • dividers.append(i)
    • return dividers