Evaluating 5!

The evaluation of 5! would proceed as shown in Fig. 6.26, which illustrates how the succession of recursive calls proceeds until 1! is evaluated to be 1, terminating the recursion. Figure 6.26(b) shows the values returned from each recursive call to its caller until the final value is calculated and returned.

Image

Fig. 6.26. Recursive evaluation of 5!.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.