FactorialWithRecursion Program
Description
This program inputs a positive integer n and then calculates n! using recursion technique.n! = n * (n - 1)* (n - 2) * ... * 1
Associated Concepts:
Recursion
Algorithm:
main method:
Declare variables.
Input an integer n from the keyboard.
Call the recursive method factorial() with n as the argument.
Print the result.
factorial method definition:
Declare variables.
Input an integer n from the keyboard.
Call the recursive method factorial() with n as the argument.
Print the result.
factorial method definition:
If the method is call with the base case: n is 0 or n is 1,
it returns the result.
Otherwise, the method returns n times factorial (n-1).
Otherwise, the method returns n times factorial (n-1).