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

Can anyone break down this Python function into steps, so I understand how it works?: http://ideone.com/vPbIX

OpenStudy (anonymous):

i also cannot understand how it works.

OpenStudy (anonymous):

is it http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes ?

OpenStudy (anonymous):

Right

OpenStudy (anonymous):

What the function does is to determine all the primes lower than 10000 and tells you how much time to determine them it took

OpenStudy (anonymous):

Store time when function was called For all number in range 'end' to '1' The number being tested (lets say x) if it is prime it only should be tested if not odd. If it is even verify if the rest the integer division of x by each number in the range 1 to sqrt (end) is 0 (prime numbers properties/theorem that states that each number to be verified as prime only need to be tested from 0 to sqrt(end)) if yes its prime store it print it whatever See current time subtract by previously stored time and print it

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!