This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 5: Breaking the flow

Newton's method with break

face Josiah Wang

Remember your solution for Newton’s method earlier?

Now, try to rewrite your solution to use break when the solution is found.

If you have already somehow used break (because you perhaps have programming experience), then do the opposite - implement your solution without a break!

If you find that there is no value in adding a break to your program, then congratulations - you have likely implemented a very compact version of the algorithm! We prefer not to have break in general, unless it improves the readability of your code.