2021-12-02 21:21:10 +01:00

36 lines
541 B
JavaScript
Executable File

function getRecursive(nr) {
console.log(nr);
getRecursive(--nr);
}
getRecursive(3);
function logRecursive(nr) {
console.log("Started function:", nr);
if (nr > 0) {
logRecursive(nr - 1);
} else {
console.log("done with recursion");
}
console.log("Ended function:", nr);
}
logRecursive(3);
function getRecursive(nr) {
console.log(nr);
if (nr > 0) {
getRecursive(--nr);
}
}
getRecursive(3);
function calcFactorial(nr) {
if (nr === 0) {
return 1;
} else {
return nr * calcFactorial(--nr);
}
}