Diferente pentru blog/primegenerator intre reviziile #1 si #2

Nu exista diferente intre titluri.

Diferente intre continut:

A while back Ovidiu Gheorgheoiu told me this neat problem:
How would you build an efficient prime number generator. Let's call a generator an object that has one method: getNextPrime(). When we call it the first time it returns 2 and every time we call it again it will return the next prime number not returned yet.
How would you build an efficient prime number generator.
 
Let the generator be an object G with the method nextPrime(). When we call it G.getNextPrime() the first time it returns 2. Every time we call it again it returns the next prime number.
So if we do:
G = PrimeGenerator()
print G.nextPrime()
print G.nextPrime()
print G.nextPrime()
We'll get
2
3
5
 
 

Nu exista diferente intre securitate.

Topicul de forum nu a fost schimbat.