Advertisement
STANAANDREY

lab3 ex16

Jan 16th, 2023
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. def minPow(a, p):
  2.     if a % p == 0:
  3.         return 0
  4.     def utilMinPow(power, n):
  5.         nonlocal a, p
  6.         if power % p == 1:
  7.             return n
  8.         return utilMinPow(power * a % p, n + 1)
  9.     return utilMinPow(a, 1)
  10.  
  11. print(minPow(a=4, p=7))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement