Yesterday few of my juniors from school were asking me for some good fast prime number finder algorithm but simple. They used to find prime numbers by testing divisibility by all integers from 2 to number-1. This is very basic routine, i remember i also used to use it when i first started. So anyway they wanted to know some fast, efficient and also simple routine to find prime number. So i told them about Eratosthenes Sieve algorithm, its fast, efficient and simple also. So i quickly wrote a module in python and gave them 🙂

def findPrimeNumbers(max):
    nlist=range(2,max+1)
    maxM=math.ceil(Math.sqrt(max))
    index=0
    while nlist[index] < maxM:
        prime=nlist[index]
        index2=index+1
        while index2 < len(nlist):
            if nlist[index2] % prime==0:
                nlist.pop(index2)
            index2+=1
        index+=1
    print nlist

Gracias