lucifer
  • lucifer
I don't understand why it says invalid syntax. the program is supposed to sum the logs of all the primes til some given number.
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 :)
SOLVED
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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
lucifer
  • lucifer
if p = x if the value of x has been assigned to p. I said both are numbers...
1 Attachment
anonymous
  • anonymous
dont forget to save your work as .py
lucifer
  • lucifer
why is that?

Looking for something else?

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

More answers

lucifer
  • lucifer
Is my style bad btw ?
anonymous
  • anonymous
you need two equal signs because you're doing a comparison and not an assignment. where your error is: instead of p=x it should be p==x
lucifer
  • lucifer
I see. it runs but doesn't do what I want :(
anonymous
  • anonymous
Hi. There seem to be a couple of issues with the function check(x) - the 'else' statement isn't indented with its matching 'if', and it seems to be eliminating any even numbers and then allocating any odd numbers to a global variable. (I've not got to the point of using global variables yet, so I can't comment on those!) Also, in checkthenmaybeaddtil(n), you're initializing S in the recursion, so it will continue to reset itself. You could initialize this outside of the function to make sure it's recognized within it? Also, x is being initialized twice - once as 'global x' (if that's how it works....) and again as part of the for statement. (I approached this problem from a completely different angle, so I'm afraid I can't be of much further help at this time GMT unless you want to take a look at a code paste!)
lucifer
  • lucifer
i do. It always helps to see other people's codes. I'm totally incompetent in programming but I would imagine that people learn to program properly just like they learn to be eloquent -- by reading eloquent writings, etc. I will now try your suggestions. bwt it is weird that I had to learn about global variables just for this assignment.
anonymous
  • anonymous
Sorry, nearly fell asleep in the shower there!! Here's a link to my code - took a few minutes to find it too: http://codepad.org/e8gDtHCd (I just iterated through for this one - didn't touch recursion until PS2) I've not touched globals yet, but I'm gonna take a break tomorrow to revise some of the readings so hopefully they'll make a bit more sense to me soon!
lucifer
  • lucifer
... it doesn't seem to work, project bloke. But I'll try to use your idea -- when I muster enough motivation. This is hard.
anonymous
  • anonymous
odd... it's working for me - just had to try it in case though :p I've actually done a little bit of programming in the past (just VB) and it IS tough to begin with, but stick in there. When the light begins to dawn, it's an amazing feeling.
lucifer
  • lucifer
oh... yes, it works. I forgot to enter testsumlogs(). sorry. this helps. thx

Looking for something else?

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