Subscribe and be notified whenever new books are published. View Sample Newsletter Or RSS Feed


The Factorial Recursive Function: A language agnostic explanation with samples in Go and JavaScript (Programming Concepts Book 1)

By: Tony de Araujo
Pages: 35

Publication Date: Feb. 19, 2016

The intent of this 30-page publication is to explain what happens when a function invokes itself and how it calculates the end result of a return statement, like for example,
return x * factorial(x-1)
When I call this function and ask for the 4 factorial, the function returns the value of 24. If you understand the steps that led to value 24 (how the calculation was made), then you don't need to read this booklet or do the exercises. However, if you are not sure how the above return statement comes up with 24 as a result since there are no obvious calculations in the script, then this booklet might help you grasp the concept.
The explanation and exercises are language independent. The examples are written in Go and JavaScript. However, the specific code discussed in the book is universal. Even if you come from another language (or have no programming experience but are curious about the subject) you should not have any problems with it. In fact, you will not be writing code at all since all exercises are done with pen and paper.