xxxxxxxxxx
import sympy
print(sympy.isprime(433101397415390663))
# output = True
xxxxxxxxxx
for i in range(2, 20):
for x in range(2, i):
if i % x == 0:
break
else:
print(i, "is a prime number")
xxxxxxxxxx
def is_prime(n: int) -> bool:
"""Primality test using 6k+-1 optimization."""
if n <= 3:
return n > 1
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i ** 2 <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
xxxxxxxxxx
def is_prime(n: int) -> bool:
"""Primality test using 6k+-1 optimization."""
import math
if n <= 3:
return n > 1
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i <= math.sqrt(n):
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
xxxxxxxxxx
num = 17
is_prime = f"number {num} is a prime number"
if num < 2:
is_prime = False
else:
for i in range(2, num):
if num % i == 0:
is_prime = f"number {num} is NOT a prime number"
break
print(is_prime)