I wrote code to calculate the 1000th prime number: http://dpaste.com/hold/640512/ . It works, but upon reviewing, I realized I do not know why. Specifically, the function that's determines prime-ness at line 20 is not in the "while loop" (lines 23-29). What is causing or commanding "x + 2" in lines 25 or 29 to be fed back into the function at line 20? It also works if I put the function in after line 29 as a recursion http://dpaste.com/hold/640514/ . Would appreciate if someone could explain the mechanics of what's going on. Thanks a lot. I wrote code to calculate the 1000th prime number: http://dpaste.com/hold/640512/ . It works, but upon reviewing, I realized I do not know why. Specifically, the function that's determines prime-ness at line 20 is not in the "while loop" (lines 23-29). What is causing or commanding "x + 2" in lines 25 or 29 to be fed back into the function at line 20? It also works if I put the function in after line 29 as a recursion http://dpaste.com/hold/640514/ . Would appreciate if someone could explain the mechanics of what's going on. Thanks a lot. @MIT 6.00 Intro Co…

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 our expert's

answer on brainly

SEE EXPERT ANSWER

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

A community for students.

I wrote code to calculate the 1000th prime number: http://dpaste.com/hold/640512/ . It works, but upon reviewing, I realized I do not know why. Specifically, the function that's determines prime-ness at line 20 is not in the "while loop" (lines 23-29). What is causing or commanding "x + 2" in lines 25 or 29 to be fed back into the function at line 20? It also works if I put the function in after line 29 as a recursion http://dpaste.com/hold/640514/ . Would appreciate if someone could explain the mechanics of what's going on. Thanks a lot. I wrote code to calculate the 1000th prime number: http://dpaste.com/hold/640512/ . It works, but upon reviewing, I realized I do not know why. Specifically, the function that's determines prime-ness at line 20 is not in the "while loop" (lines 23-29). What is causing or commanding "x + 2" in lines 25 or 29 to be fed back into the function at line 20? It also works if I put the function in after line 29 as a recursion http://dpaste.com/hold/640514/ . Would appreciate if someone could explain the mechanics of what's going on. Thanks a lot. @MIT 6.00 Intro Co…

MIT 6.00 Intro Computer Science (OCW)
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

your prime test function is in the while loop on line 24 and 26. As for what causes your function to iterate, it is because you are using a while loop which will do whatever is in it while a condition is or is not met... does that make sense?
Yeah, that does make sense, thanks a lot. I was thinking about lines 24 and 26 as checking the result of 20, but now I see what's going on.
Further in view of this explanation, I see that the function at line 20 is superfluous, since all the action is taking place in the while loop. I deleted line 20 and it returns the correct answer.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question