PS1: How'd I do? Here's my code, what do you guys think? x = 3 z = 3 w = 999 while w > 0: if x%z != 0: z = z + 2 else: if x == z: w = w - 1 # print x x = x + 2 z = 3 else: x = x + 2 z = 3 else: x = x - 2 print x # print 'edn'
its alright
it works for problem #1, but where the second part? heres how i solved PS 1: from math import * #problem 1 primes = () for n in range(2, 7920): for i in range(2, n): if n % i == 0: break else: primes = primes + (n, ) #Problem 2 add = 0 l = 0 for x in range(0,1000): z = primes [x] ## print z add += log(z) print add / primes [x] ## print add, primes [x], add/ primes [x] what do you think?
See, I thought they wanted us to do a looping program. They asked us to generate possible solutions, test them, and use some end test which will stop the loop. Yours is great though. It looks a whole lot cleaner than mine. It appears that you have watched a few more video lectures than me. haha
Join our real-time social learning platform and learn together with your friends!