Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 25 Online
OpenStudy (anonymous):

Im having a tough time figuring out what problem set 1, problem 2 is asking me to accomplish. Could someone break it down for me ?

OpenStudy (anonymous):

Hi, Discorick. What they're looking for is a program where you add up all the logarithms of the prime numbers from 2 to a given number 'n'. You'll change 'n' each time you run the program to see how it works. Then at the end of the program, you need to print the sum of the logarithms, the number 'n' that you used, and then the ratio you get when you divide the sum by 'n'. So you want a program that has a variable 'n' that you can change. Then you'll want it to find all the prime numbers from 2 up to 'n'. (You can adapt your code from problem 1 for that.) For each prime number, you want to take its logarithm and add that to a running total. Then, just print out your running total of the logs, the 'n' that was used, and the ratio of those two. If your program works right, you should see that the ratio gets closer and closer to 1 as you increase 'n'.

OpenStudy (anonymous):

I think you could benefit from some discreet math. The math for comp science 1 will help you to mathematically define what an odd and even number is. All primes are odd.

OpenStudy (anonymous):

Pay particular attention to lecture 2 approximately 30 minutes in.

OpenStudy (anonymous):

Thanks for the clarification Paul! I am going to give problem 2 another shot tonight. And yeah I will be applying myself to some math courses aswell.

OpenStudy (anonymous):

Here is what I wrote to solve this: http://codepad.org/cq2mAjCE If you have a quick chance to verify I am producing the proper result thanks! I do realize this could coded more efficiently, I copy-pasted my prime number generator.

OpenStudy (anonymous):

Just stick it out, your neurons will start popping and you'll be wondering why any of it ever gave you a lick of trouble.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!