Lesson 10: First 100 prime numbers

posted Jan 9, 2020, 8:00 AM by Attila Lengyel
print(10%3)
print(15%6)

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

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

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

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

if spoungebob(n):
print("Spounge Bob says", n, "is a prime number")
else:
print("Spounge Bob says", n, "is not a prime number")

counter = 0
n = 0
while counter <= 1000:
n = n + 1
if spoungebob(n):
print(counter, n)
counter = counter + 1





Comments