I have been working through the ps1a and ps1b questions and am slowly getting there but i am not sure what is being asked in 1b i have the sum of the logs but i don't understand the ratio part.
Here is what i have so far http://ideone.com/F8uXP
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Ratio is just the division of a quantity by another. If I recall correctly, you should divide the sum of log ( logprime1 + logprime2 ... ) by the log of the sum ( log ( prime1 + prime2 + prime 3 + ... + prime1000 ) )
But I don't remember exactly what are the order to divide. Check the pset pdf, should be clear there.
Let's take a simple case to understand the computation. Suppose we are trying to find the 10th prime number.
The 10th prime number is: 29
The series is : [2,3,5,7,11,13,17,19,23,29]
Logsum = log(2)+log(3)+...log(29)
The ratio is: Logsum/N
Your output should look like below. Notice as N increases the ratio converges to 1:
@hich prime number do you want me to find: 10
The 10th prime is: 29
The ratio of LogSum/N is: 0.79659379841
Which prime number do you want me to find: 100
The 100th prime is: 541
The ratio of LogSum/N is: 0.935909535582
Which prime number do you want me to find: 1000
The 1000th prime is: 7919
The ratio of LogSum/N is: 0.986588504402
Thank you both
here is my updated code any comments welcome but it works so i am happy
Not the answer you are looking for? Search for more explanations.
For some reason, my ratios are somewhat different than yours.
here's my code for the ratio:
z = 2
a = 0
b = 0
while z <= x:
n = 2
while z%n != 0:
n = n + 1
if n == z:
a = z
b = b + log(a)
Any thoughts on why that is?
My understanding of the assignment was that the ratio is between the sum of the logs of the primes smaller then or equal to the number 'n', and the number 'n'.
If I'm not mistaken, the number 'n' is not necessarily prime. Am I right?
For example: Say the number 'n' chosen is 15.
The primes up to n would be: 2,3,5,7,11,13
So, it should do (log2 + log 3+ log 5 + log 7 + log 11 + log 13)/15
@Efarias. That's correct. n is the number that you are counting up to. But as the numbers get large the ratio will come out approximately the same whether you use, for example, 13 or 15.
@EFarias. Let me check.
@EFarias. Your code checks and the ratio is also correct. I will explain tomorrow why there is a discrepancy in our results. There isn't a real discrepancy. You did a good job and have gotten the correct result.
@malpaso. That´s good news! Looking forward to your explanation! Thanks!