So I am on ps1pr2. Through reading here, I figured out the first problem and here is my code. I tweaked it a little to fit the second problem and let the user input to what prime is being calculated:
My next question is what should my next step be? I am at a bit of a loss as how to calculate the sums of the logs. Should I assign a new variable (sumoflog), and then just keep adding to that as I work through the prime numbers?
MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.
Sorry, I used "answer" as a variable in my additional code that lets the user put in a number. Makes is a little confusing.
Yes. Start a new variable at the beginning of your program that will keep track of the sum of the logs of the prime numbers. Since you assume that 3 is already a prime number, you should set the variable initially as:
as you cycle through the primes sumoflog should increase
you will use a statement such as
sumoflog+=log(n) where n is a number that you have determined is a prime
Thanks for the heads up malpaso. As I was writing my question it began to make more sense, but your additional explanation will really help me out.