106. Inductive and recursive
Definition 105.1 gives the value at $n$ in terms of the value of the function at a smaller integer. In general, a function $F\colon \mathrm{N} \to \mathrm{N}$ is defined by induction if certain initial values $F (0),F (1),\ldots ,F (k)$ are defined and for each $n \in \mathrm{N}$, $F (n+ 1)$ is defined in terms of some or all of the preceding values $F (0),F (1),\ldots ,F (n)$. Thus inductive definition is a special case of recursive definition. In a more formal treatment of this subject, the phrase “in terms of” would have to be precisely defined.
Recursive definitions which are not inductive may involve domains other than $\mathrm{N}$ which have no natural ordering (so that “in terms of smaller values” makes no sense) or functions on $\mathrm{N}$ which involve definition in terms of both larger and smaller values. The general concept of recursion is fundamental to much of theoretical computer science. It is a common theme uniting the different threads in [Hofstadter, 1979].
106.1.1 Example The ninety-one function $F\colon \mathrm{N} \to \mathrm{N}$ is defined by:
$$F (n) = \begin{cases} F\bigl(F (n+ 11)\bigr) & (n \leq 100) \\ n-10 & (n >100) \end{cases} \tag{106.1}$$
This is a well defined function. It has the property that $F (n) = 91$ if $n \leq 100$ and $F (n ) =n-10$ if $n >100$.
106.1.2 Example The Collatz function $T\colon \mathrm{N}^{+} \to \mathrm{N}^{+}$ defined by:
$$T (n) = \begin{cases} 1 & (\text{if } n= 1) \\ T\left(\frac{n}{2}\right) & (\text{if } n \text{ is even}) \\ T (3n+ 1) & (\text{if } n \text{ is odd and } n >1) \end{cases}$$
Looking at the formula, there is no reason to believe that the computation wouldn’t loop forever for some value of the input, but no one has ever been able to discover such a value or to prove that such a value does not exist. (Every input that has ever been computed does in fact given an answer, namely 1.) In other words, although we called it “the Collatz function”, we don’t actually know that it is a function! Note that if you change the ‘$3n+ 1$’ to ‘$3n-1$’ in the third line, then $T$(5) is not defined. There is much more about this in [Guy, 1981], Problem E-16, page 120 and in [Lagarias, 1985].
106.1.3 Exercise (hard) Prove that the ninety-one function defined by Equation (106.1) on page 159 satisfies $F (n) = 91$ if $n\leq 100$ and $F (n ) =n-10$ if $n >100$.
Pages 159–160 of the book (PDF).