| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Math.Prime
Documentation
smallPrimes :: Integral i => [i] Source #
primeFactors :: Integral i => i -> [i] Source #
>>>primeFactors 60[2,2,3,5]>>>primeFactors 0[]>>>primeFactors 1[]>>>primeFactors 2[2]>>>primeFactors 2147483647[2147483647]>>>primeFactors 999999999989[999999999989]>>>primeFactors 999999999997[5507,181587071]
isPrime :: Integral i => i -> Bool Source #
>>>isPrime 4649True>>>isPrime 0False>>>isPrime 1False>>>isPrime 2True>>>isPrime 2147483647True>>>isPrime 999999999989True>>>isPrime 999999999997False
totient :: Int -> Int Source #
\n -> not (n >= 0) || totient n == length [x|x<-[1..n], gcd n x == 1]
+++ OK, passed 100 tests.
>>>totient 00>>>totient 11
divisors :: Int -> [Int] Source #
>>>divisors 12[1,2,3,4,6,12]>>>divisors 0[1]>>>divisors 1[1]>>>length (divisors 735134400)1344
moebius :: Int -> Int Source #
>>>moebius 11>>>moebius 2-1>>>moebius 3-1>>>moebius (2 * 2)0>>>moebius (2 * 3)1>>>moebius (2 * 2 * 3)0
moebiusInversion :: Num a => Int -> (Int -> a) -> IntMap a Source #
>>>moebiusInversion 12 (length.divisors)fromList [(1,1),(2,1),(3,1),(4,1),(6,1),(12,1)]>>>moebiusInversion 999999999997 (length.divisors)fromList [(1,1),(5507,1),(181587071,1),(999999999997,1)]>>>IM.size $ moebiusInversion 735134400 (length.divisors)1344