Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def minPow(a, p):
- if a % p == 0:
- return 0
- def utilMinPow(power, n):
- nonlocal a, p
- if power % p == 1:
- return n
- return utilMinPow(power * a % p, n + 1)
- return utilMinPow(a, 1)
- print(minPow(a=4, p=7))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement