Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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 4649
True>>>
isPrime 0
False>>>
isPrime 1
False>>>
isPrime 2
True>>>
isPrime 2147483647
True>>>
isPrime 999999999989
True>>>
isPrime 999999999997
False
totient :: Int -> Int Source #
\n -> not (n >= 0) || totient n == length [x|x<-[1..n], gcd n x == 1]
+++ OK, passed 100 tests.
>>>
totient 0
0>>>
totient 1
1
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 1
1>>>
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