anonymous
  • anonymous
Can someone please review my ps1b? I'd appreciate any feedback. import math def isPrime(num): if num > 1: if num == 2: return 1 i = 2 while i < math.sqrt(num) + 1: if num%i == 0: return 0 else: i += 1 return 1 else: return 0 def ps2(num): i = 2 j = 0 logsum = math.log(2) while j < num: if isPrime(i) == 1: j += 1 logsum += math.log(i) if j == num: print "N: ",num print "Sum of logs: ",logsum print "Ratio: ",num/logsum i = i + 1 ps2(input("Enter a number: "))
MIT 6.00 Intro Computer Science (OCW)
schrodinger
  • schrodinger
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
sorry function ps2 should be called something like printLogInfo
anonymous
  • anonymous
2 problems. 1) The ratio should be the (sum of logs not including the nth prime)/the nth prime. In your problem, you divide 1000 by the sum of logs including the nth prime. This is wrong. 2) Note that you must not include the math.log(7919) in your Sum. The sum should be close to 7803 I believe. 3) I checked your problem. You add math.log(2) twice in your problem. Remove one to get 7803.3 which is the correct answer.
anonymous
  • anonymous
Thanks!

Looking for something else?

Not the answer you are looking for? Search for more explanations.