Poll & solutions
Nov. 11th, 2009 10:52 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
First:
Also, it occurs to me that it might be handy to have a place to post/discuss solutions to the problem sets, to see what we can learn from each other in the absence of TAs. If you actually go to MIT and the problem sets are still the same, don't read these. ;)
Fire away!
Open to: Registered Users, detailed results viewable to: All, participants: 25
Tickyboxes!
Also, it occurs to me that it might be handy to have a place to post/discuss solutions to the problem sets, to see what we can learn from each other in the absence of TAs. If you actually go to MIT and the problem sets are still the same, don't read these. ;)
Fire away!
Problem 1a
Date: 2009-11-15 10:30 pm (UTC)from math import *
target_primes = 1000 #nth prime that we want to compute
current_no = 3
prime_counter = 2
i = 3
while prime_counter < target_primes:
prime_counter += 1
current_no += 2
i = 3
while i <= sqrt(current_no):
if current_no%i == 0:
current_no += 2
i = 3
else:
i += 2
print str(current_no) + " is the " + str(prime_counter) + "th prime."
(Now with better formatting here.)
Not actually better formatting
Date: 2009-11-15 10:32 pm (UTC)