Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

in ps1 i can generate primes but the problem with output is that it is painfully repetitive. the code is here http://codepad.org/9ZdIo1Cv suggestions and modifications required......

OpenStudy (rsmith6559):

This is what I did for ps1: import math primes = [ 2, 3 ] testNum = 5 numberOfPrimes = 10000 while( len( primes ) < numberOfPrimes ): for i in xrange( 0, len( primes ) ): if( testNum % primes[i] ): if( i == ( len( primes ) - 1 )): primes.append( testNum ) else: break testNum += 2 lastPrime = primes[len( primes ) - 1] print "The", str( numberOfPrimes ) + "th prime is:", lastPrime

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!