reorganizing some more
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user