def isPrime(x):

for i in range(2, x):

if x%i == 0:

return false

return true

for c in range(1,10):

if isPrime(c):

print c,

output:for i in range(2, x):

if x%i == 0:

return false

return true

for c in range(1,10):

if isPrime(c):

print c,

>>> 1 2 3 5 7

Showing posts with label **prime number**. Show all posts

Showing posts with label **prime number**. Show all posts

This Python script will generate a list of prime number.

def isPrime(x):

for i in range(2, x):

if x%i == 0:

return false

return true

for c in range(1,10):

if isPrime(c):

print c,

output:for i in range(2, x):

if x%i == 0:

return false

return true

for c in range(1,10):

if isPrime(c):

print c,

>>> 1 2 3 5 7

Subscribe to:
Posts
(
Atom
)