Published
Edited
Dec 5, 2020
95 forks
19 stars
Insert cell
Insert cell
Insert cell
Insert cell
function iterativeFactorial(n) {
let product = 1;
while (n > 0) {
product *= n;
n--;
}
return product;
}
Insert cell
iterativeFactorial(3) // Try changing the input to test out the function
Insert cell
function recursiveFactorial(n) {
if (n === 0) return 1;
return n * recursiveFactorial(n - 1);
}
Insert cell
recursiveFactorial(3) // Try changing the input to test out the function
Insert cell
Insert cell
function iterativeFibonacci(n) {
// TODO your code goes here
}
Insert cell
Insert cell
function recursiveFibonacci(n) {
// TODO your code goes here
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
iterativeFibonacci(n)
Insert cell
recursiveFibonacci(n)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more