Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function factorial(number) {
- var currentNum = null;
- if (number == 1) {
- print("number is now 1");
- return number;
- }
- else {
- currentNum = number * factorial(number - 1);
- print("Current number is", number);
- print("Current return of the function is", currentNum);
- return currentNum;
- }
- }
- print(factorial(5));
- // when a function is called recursively, the results of the function's computation
- // are temporarily suspended while the recursion is in progress.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement