MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / fast_exp

Function fast_exp

Python/CP_Templates.py:6–13  ·  view source on GitHub ↗
(base, power)

Source from the content-addressed store, hash-verified

4
5
6def fast_exp(base, power):
7 result = 1
8 while power > 0:
9 if power % 2 == 1:
10 result = (result * base) % m
11 power = power // 2
12 base = (base * base) % m
13 return result
14
15
16# n**0.5 complexity

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected