June 2007
Intermediate to advanced
294 pages
8h 6m
English

This chapter shows some recursive and other functional solutions to simple problems, as well as some ways we can test and improve these solutions. Two very common programming topics that demonstrate functional programming are the factorial and Fibonacci mathematical series—largely because they’re so easily described using recursive means.[20]
The factorial of a given positive number is the product of all the integers from 1 to that number, so factorial(3) = 3 x 2 x 1, factorial(5) = 5 x 4 x 3 x 2 x 1, and so on. This can be expressed generally as:
factorial(x) = x x (x – 1) x (x – 2) ...
Read now
Unlock full access