Processing math: 100%
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Engineering LibreTexts

5.3: Infinite Loops

( \newcommand{\kernel}{\mathrm{null}\,}\)

An endless source of amusement for programmers is the observation that the directions on shampoo, "Lather, rinse, repeat," are an infinite loop because there is no iteration variable telling you how many times to execute the loop.

In the case of countdown, we can prove that the loop terminates because we know that the value of n is finite, and we can see that the value of n gets smaller each time through the loop, so eventually we have to get to 0. Other times a loop is obviously infinite because it has no iteration variable at all.


This page titled 5.3: Infinite Loops is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Chuck Severance.

  • Was this article helpful?

Support Center

How can we help?