Factors of an integer: Difference between revisions
→{{Header|Haskell}}: Used an arrow operator to simplify an expression
(→{{Header|Haskell}}: Used an arrow operator to simplify an expression) |
|||
Line 1,800:
The above function can also be found in the package [http://hackage.haskell.org/package/arithmoi <code>arithmoi</code>], as <code>Math.NumberTheory.Primes.factorise :: Integer -> [(Integer, Int)]</code>, [http://hackage.haskell.org/package/arithmoi-0.4.2.0/docs/Math-NumberTheory-Primes-Factorisation.html which performs] "factorisation of Integers by the elliptic curve algorithm after Montgomery" and "is best suited for numbers of up to 50-60 digits".
Or,
<lang Haskell>
integerFactors ::
integerFactors n
| n < 1 = []
| otherwise =
lows ++
(if
then tail
else id)
(reverse (quot n <$> lows))
where
(squared, lows) =
intRoot = floor (sqrt $ fromIntegral n)▼
main :: IO ()
|