adalah Python utama
def is_prime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
Mouad En-naciry
def is_prime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
n = 20
primes = []
for i in range(2, n + 1):
for j in range(2, int(i ** 0.5) + 1):
if i%j == 0:
break
else:
primes.append(i)
print(primes)
import math
def isPrimeNumber(n):
if (n < 2):
return False;
sq = int(math.sqrt(n))
for i in range(2, sq + 1):
if (n % i == 0):
return False
return True
from math import sqrt
for i in range(2, int(sqrt(num)) + 1):
if num % i == 0:
print("Not Prime")
break
print("Prime")
# Note: Use this if your num is big (ex. 10000 or bigger) for efficiency
# The result is still the same if the num is smaller
until = 20
[n for n in range(2, until) if all(n % m != 0 for m in range(2, n-1))]
a=int(input('number:'))
if a % 2 ==0 and a / 2 <= 2:
print('composite')
elif a % 3 == 0 and a/3 <= 2:
print('composit')
elif a % 5 == 0 and a/5 <= 2 :
print('composit')
elif a % 7 == 0 and a/7 <= 2:
print('composit')
else:
print('prime')
________________________________________________________________________________