| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
AtCoder.Internal.Math
Description
Internal math implementation.
Example
>>>import AtCoder.Internal.Math>>>powMod 10 60 998244353 -- 10^60 mod 998244353526662729
>>>isPrime 998244353True
>>>isPrime 4False
>>>invGcd 128 37(1,24)
>>>24 * 128 `mod` 37 == 1True
>>>primitiveRoot 21307064333
>>>floorSumUnsigned 8 12 3 56
Since: 1.0.0.0
Documentation
powMod :: HasCallStack => Int -> Int -> Int -> Int Source #
Returns \(x^n \bmod m\).
Constraints
- \(0 \le n\)
- \(1 \le m\)
Complexity
- \(O(\log n)\)
Example
>>>let m = 998244353>>>powMod 10 60 m -- 10^60 mod m526662729
Since: 1.0.0.0
isPrime :: Int -> Bool Source #
M. Forisek and J. Jancina, Fast Primality Testing for Integers That Fit into a Machine Word
Since: 1.0.0.0
invGcd :: Int -> Int -> (Int, Int) Source #
Returns \((g, x)\) such that \(g = \gcd(a, b), \mathrm{xa} = g(\bmod b), 0 \le x \le b/g\).
Constraints
- \(1 \le b\) (not asserted)
Since: 1.0.0.0
primitiveRoot :: Int -> Int Source #
Returns primitive root.
Since: 1.0.0.0