Ok, my BA is in English, and I work as a translator, so math isn't precisely my forté. Ps1b mentions logarithms and ratios. Now, I created code that generates logs on base10, assuming this what is required, since, when I punch the "log" button on a scientific calculator, this seems to be the value I get. And a ratio, well, the assignment doesn't specify, the ratio of the sum of the logs of the primes to n, or the ratio of n to the sum? It's a bit confusing. Supposedly this ratio should approach one, but when I run my code, it never reaches .5, throwing big numbers at it (which takes forever).
I think my code is good, but I feel like maybe I'm not correctly understanding the math involved. (The course didn't mention any math prequisites, either). Here's my code: http://pastebin.com/iZ3Q5EQ2
The value of the ration of the sum of the logs of the primes to the value n DOES grow, but at n=999999 it is still less than 0.5. I tried 9999999, but it was taking FOREVER and I think my CPU was smoking, so I dumped the script with ctrl+z.
I posted the code on my wiki, and pasted in some of the results. I don't know, but maybe I didn't do so bad for an English major, after all... http://baldwinsoftware.com/wiki/pmwiki.php?n=MIT.Ps1b I just hope there's not going to be tons more of this confusing math stuff. I have difficulty balancing a checking acct.
"Have a nice day." You're program is so polite. I'll be anxiously awaiting a reply from someone because the math has me confused, too.
from the pset instruction: "...(that is, the ratio of the product of the primes to e**n gets close to 1 as n grows). ..." without the maths i imagine \it wasn't clear. e is the base for natural logarithms so you should be using natural logs. http://docs.python.org/library/math.html#math.log there is an assumption of basic maths \in this course so if your not sure just ask here.
Tony, the course isn't all math, but programming itself does always involve it. For most programming, it's not to this extent. As you go along through the course, you'll see the math portion of it slowly fall away, but never completely.
Join our real-time social learning platform and learn together with your friends!