filmov
tv
C Programming | Factorial of a Number Using Recursion

Показать описание
#cprogramming #shorts
C Programming | Factorial of a Number Using Recursion
Example Guide:
Suppose the user entered 4.
Initially, multiplyNumbers() is called from main() with 4 passed as an argument.
Then, 3 is passed to multiplyNumbers() from the same function (recursive call). In each recursive call, the value of argument n is decreased by 1.
When the value of n is less than 1, there is no recursive call and the factorial is returned ultimately to the main() function.
So the final value would like
4 * 3 * 2 *1 = 24
C Programming | Factorial of a Number Using Recursion
Example Guide:
Suppose the user entered 4.
Initially, multiplyNumbers() is called from main() with 4 passed as an argument.
Then, 3 is passed to multiplyNumbers() from the same function (recursive call). In each recursive call, the value of argument n is decreased by 1.
When the value of n is less than 1, there is no recursive call and the factorial is returned ultimately to the main() function.
So the final value would like
4 * 3 * 2 *1 = 24