/next-level-recursion

Source code for the Dev.to article on recursion after factorials and Fibonacci

Primary LanguageJavaScriptCreative Commons Zero v1.0 UniversalCC0-1.0

next-level-recursion

Source code for the Dev.to article on recursion after factorials and Fibonacci

Source Code

The following files demonstrate three different recursive functions, two simple and one more complicated. The simple examples are accompanied by there iterative counterparts.

Simple (textbook) examples

  • 1a: Factorial - iterative, using a for loop (factorial-i))
  • 1b: Factorial - recursive (factorial-r)
  • 2a: Fibonacci - iterative, using a for loop (fibonacci-i)
  • 2b: Fibonacci - recursive (fibonacci-r)

Complicated example

  • 3a: objectFlat - initial (objectFlat_initial)
  • 3b: objectFlat (objectFlat)

Executing the examples

To execute the tests for a specific function use the following command in a terminal session.

npm run <example> where <example> is something like 1a or 3b.

Pre-requisites

  1. Install Node.js
  2. No need to execute npm install because there are no 3rd-party dependencies.