## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Chapter 7. Using, Optimizing, and Testing Functional Techniques

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) ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required