module Numeric.NumberTheory ( totient
, tau
, littleOmega
, isPerfect
) where
import Foreign.C
import Numeric.Common
foreign import ccall unsafe totient_ats :: CInt -> CInt
foreign import ccall unsafe count_divisors_ats :: CInt -> CInt
foreign import ccall unsafe little_omega_ats :: CInt -> CInt
#if __GLASGOW_HASKELL__ >= 820
foreign import ccall unsafe is_perfect_ats :: CInt -> CBool
#else
foreign import ccall unsafe is_perfect_ats :: CInt -> CUChar
#endif
isPerfect :: Int -> Bool
isPerfect = convertBool . is_perfect_ats . fromIntegral
littleOmega :: Int -> Int
littleOmega = conjugate little_omega_ats
tau :: Int -> Int
tau = conjugate count_divisors_ats
totient :: Int -> Int
totient = conjugate totient_ats