Category: Python

Python: Prime Number

April 15th, 2008 | No Comments | Print

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:

>>> 1 2 3 5 7

Recommended Reading

Like this article?

Subscribe to the  RSS feed, or to  daily email updates, right now!

Share and enjoy:  Digg  del.icio.us  TwitThis  Facebook

Leave a Reply