Recursive Factorial

A recursive definition of the factorial function is arrived at by observing the following algebraic relationship:

n! = n  ·  (n – 1)!

For example, 5! is clearly equal to 5 * 4! as is shown by the following:

5! = 5 · 4 · 3 · 2 · 15! = 5 · (4 · 3 · 2 · 1)5! = 5 · (4!)

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.