Lesson 11: Prime numbers and functions

posted Jan 7, 2020, 8:01 AM by Attila Lengyel
print(10%2)

for i in range(1,10):
print("10 modulo", i, "is", 10%i)


n = int(input("Give me a number:"))

prime = True
for i in range(2, n):
if n%i == 0:
prime = False
break

if prime == False:
print(n, "is not a prime number")
else:
print(n, "is a prime number")

def isprime(n):
prime = True
for i in range(2,n):
if n%i == 0:
prime = False
break
return prime

if isprime(n) == False:
print(n, "is not a prime number")
else:
print(n, "is a prime number")

for i in range (1,1000):
if isprime(i):
print(i)
Comments