prvocislo.py 329 Bytes
Newer Older
cermak's avatar
cermak committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python3
# %%

import random

N = 100

def is_probably_prime(p):
    for _ in range(N):
        a = random.randrange(1e10)
        if a % p != pow(a, p, p):
            return False
    return True

# %%
print(f"{is_probably_prime(13)=}")
print(f"{is_probably_prime(1453453)=}")
print(f"{is_probably_prime(2396279)=}")