TI-Basic 84 Programming/Recursion

Recursion in programs involves calling up the program to run again from the beginning. If not done carefully it can create infinite loops of code that won't terminate. If you run a program that gets stuck in a loop you can press the On button; the On button terminates execution of any program.

How to do it
Writing code that does is simple, within the program you simply have a call to the current program. The syntax is PRGM:EXEC then whatever program.

If you use recursion you always want to have some condition that has to be met in order for the recursive call to happen. An easy way to do this is to encapsulate the recursive call in an "If" statement or a while loop.

Example
In this example we will write a simple counting program. Before we run this program we have to set X to a number, for this example we will assume it has been set to 0.