MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / rabin_miller

Function rabin_miller

ciphers/rabin_miller.py:6–25  ·  view source on GitHub ↗
(num: int)

Source from the content-addressed store, hash-verified

4
5
6def rabin_miller(num: int) -> bool:
7 s = num - 1
8 t = 0
9
10 while s % 2 == 0:
11 s = s // 2
12 t += 1
13
14 for _ in range(5):
15 a = random.randrange(2, num - 1)
16 v = pow(a, s, num)
17 if v != 1:
18 i = 0
19 while v != (num - 1):
20 if i == t - 1:
21 return False
22 else:
23 i = i + 1
24 v = (v**2) % num
25 return True
26
27
28def is_prime_low_num(num: int) -> bool:

Callers 1

is_prime_low_numFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected