src/pylib/builtins/modPow

Search:
Group by:
Source   Edit  

Procs

func pow(base, exp, modulo: int): int {....raises: [ValueError], tags: [],
                                        forbids: [].}

Example:

assert pow(10, 20, 3) == 1  # 10^20 is bigger than `high int64`
assert pow(7, 2, 13) == 10
assert pow(7, 20, 13) == 3
doAssertRaises ValueError:
  discard pow(1000, -2, 2)
  # base is not invertible for the given modulus
assert pow(1234, 20, 73) == 9
Source   Edit