anonymous
  • anonymous
Can someone help me understand how this code works? I am not familiar with how the break command works. i = 2 while(i < 100): j = 2 while(j <= (i/j)): if not(i%j): break j = j + 1 if (j > i/j) : print i, " is prime" i = i + 1 print "Good bye!"
MIT 6.00 Intro Computer Science (OCW)
chestercat
  • chestercat
See more answers at brainly.com
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

KonradZuse
  • KonradZuse
while continues until some condition is met, then stops. You can also break out of the while loops with the break command.
anonymous
  • anonymous
'break' jumps you out of the while(j ... loop. If j is a factor of i, then i is not prime, so you don't need to test any further values of j.
rsmith6559
  • rsmith6559
while continues until some condition is NOT met, then stops. If the condition returns true, the code block is executed. If the condition returns false, the code block is skipped.

Looking for something else?

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

More answers

KonradZuse
  • KonradZuse
^That is more technically correct "Not met." :p
anonymous
  • anonymous
Got it. Thanks.
anonymous
  • anonymous
break lets you skip a snippet of code

Looking for something else?

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