Thursday, September 9, 2010

New Sieve, and tomorrow's workout

Tomorrow's workout will be:
B Squat: 300 x 5s x 5r
Bench: 207.5 x 6s x 5r
Bicep Curls: 107.5 x 8s x 5r



Wrote a new sieve of Eristaphanes. Think it's more efficient, but will have to check.
Code is below.

upper_limit = raw_input("\n\nUp to what number should be search for \
perfect numbers?\n")

upper_limit = int(upper_limit)

the_range = range(0,upper_limit + 1)
potential_answers = list(the_range)

print "The list of numbers being evaluated is", potential_answers,"\n\n"



for n in the_range:
a = 2
if n % a == 0:
potential_answers.remove(n)
else:
while a < n/2:
a +=1
if n % a == 0:
if n in potential_answers:
potential_answers.remove(n)

print "\nThe perfect numbers in the range you provided are ", potential_answers

No comments:

Post a Comment

Followers