| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Euler.Util.Arithmetic
Documentation
>>>import Test.QuickCheck
Functions
divides :: Integral a => a -> a -> Bool Source #
a ` iff a is a divisor of b; in other words, b = 0 (mod
a).divides` b
intSqrt :: Integral a => a -> Maybe a Source #
is the integer r such that r^2 = x, if such an integer exists.intSqrt x
\(NonNegative n) -> intSqrt (n^2) === Just n
\(Positive n) -> intSqrt(n^2 + 1) === Nothing
\(Positive n) -> intSqrt((n+1)^2 - 1) === Nothing
floorSqrt :: Integral a => a -> a Source #
is the largest integer r such that r^2 <= x.floorSqrt x
\(NonNegative n) -> floorSqrt (n^2) === n
\(Positive n) -> floorSqrt(n^2 + 1) === n
\(Positive n) -> floorSqrt((n+1)^2 - 1) === n
isSquare :: Integral a => a -> Bool Source #
iff isSquare xx is a square.
\(NonNegative n) -> isSquare (square n)
\(Positive n) -> not (isSquare $ (square n) + 1)
Factorial
Functions
factorial :: Integral a => a -> Integer Source #
(often written as n!) is the product of the integers from 1 to
n, inclusive.factorial n
factorials :: [Integer] Source #
All of the factorials, ascending. Equivalent to .map factorial [0..]
>>>take 10 factorials[1,1,2,6,24,120,720,5040,40320,362880]