Factorise a number into a product of prime powers. Factorisation of 0
is an undefined behaviour. Otherwise following invariants hold:
abs n == abs (product (map (\(p, k) -> unPrime p ^ k) (factorise n)))
all ((> 0) . snd) (factorise n)
>>> factorise (1 :: Integer)
[]
>>> factorise (-1 :: Integer)
[]
>>> factorise (6 :: Integer)
[(Prime 2,1),(Prime 3,1)]
>>> factorise (-108 :: Integer)
[(Prime 2,2),(Prime 3,3)]
This function is a replacement for
factorise. If you were
looking for the latter, please import
Math.NumberTheory.Primes.Factorisation instead of this module.
Warning: there are no guarantees of any particular order of
prime factors, do not expect them to be ascending. E. g.,
>>> factorise 10251562501
[(Prime 101701,1),(Prime 100801,1)]