Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1.  s = 0
  2.     r = n - 1
  3.  
  4.     while r & 1 == 0:
  5.         s += 1
  6.         r //= 2
  7.     for _ in range(k):
  8.         a = random.randrange(2, n)
  9.         x = pow(a, r, n)
  10.         if x != 1 and x != n - 1:
  11.             j = 1
  12.             while j < s and x != n - 1:
  13.                 x = pow(x, 2, n)
  14.                 if x == 1:
  15.                     break
  16.                 j += 1
  17.             if x != n - 1:
  18.                 break
  19.         flag = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement