elz (
elz) wrote in
intro_to_cs2009-11-11 10:52 pm
Entry tags:
Poll & solutions
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!
no subject
def find_nth_prime(prime_to_find): n = 1 primes = [] if prime_to_find < 1: print "Please enter a number greater than zero." return None else: while len(primes) < prime_to_find: if len(primes) == 0: primes.append(2) print "%i is prime number #%i" % (primes[0], len(primes)) else: root = math.sqrt(n) for prime in primes: if n%prime == 0: break elif prime > root: primes.append(n) print "%i is prime number #%i" % (n, len(primes)) break n = n + 2 return primes[prime_to_find - 1]