These are demo tests for the Javascript recursion exercises found on the this webpage.
Tests are done with the QUnit framework, split into modules using RequireJS. Each exercise has at least 5 tests with various input to assert the results.
Loading up index.html
will show the results of the tests done for each exercise.
Quoted from the website:
- Sum: Find the sum of a sequence of numbers recursively.
- Exponent: Find the result of 8^2 recursively.
- Factorial: The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. Find 5! recursively.
- Fibonacci: The first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is the sum of the previous two. Produce the sequence recursively.
- Range sequence: Recursively produce a sequence of numbers from 3 to 9 with exclusive bounds.
- Greatest common divisor: The greatest common divisor (gcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. Recursively find the greatest common divisor of a sequnce of values.
- All input values are assumed to be number values, not numbers represented as strings.
- Decimals can sometimes lead to erroneous results, since floating point arthmetic can be imprecise.
- For simplicity, exponents must be integers.
- Sequence begins at the the traditional [0, 1, 1, ...].
- For simplicity, numbers must be integers and at least greater than or equal to zero.