anonymous
  • anonymous
ps1 def pr(x): print'2' n=1 som=0 prod=1 ## odds= 2*n+1 cmpt=1 ## j=2 ## prim = True while cmpt < x: ## n=n+1 odds=2*n+1 j=2 prim= True while (j < odds) and (prim == True): if odds%j==0: prim = False else: j=j+1 if prim == True: print (n, odds,cmpt) som=som+odds prod=prod*odds print( som, prod) cmpt=cmpt+1
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.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Wow you need to use pastebin. also try to use more descriptive names it will make it easier to read. I think you are asking about the prime number exercise. Start with the premise that the number you are testing is prime and test for falseness. like this is_prime = True if the number is 1 then return false do a loop while the index is less then or equal to the square of the number to check if number % index == 0 then return false index = index + 1 return True So as you can see from the pseudo code that all you do is see if there is a remainder.
anonymous
  • anonymous
my code work but thanks for your advices jimtuv

Looking for something else?

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