C++ Program to find the Factorial of a Number using Recursion

preview_player
Показать описание
In this video you will learn to write a C++ Program to find the factorial of a number using Recursion ( Recursive Method ).

The factorial of a positive integer n, which is denoted as n!, is the product of all positive integers less than or equal to n.

That is n! = n * (n-1)*(n-2)*....*3*2*1

So 4! = 4 * 3 * 2 * 1 which is equal to 24.

Factorial for the numbers 0 and 1 is 1. That is 0! = 1 and 1! = 1. For negative numbers factorial value doesn't exists.

C++ Program to Find the Factorial of a number using Iterative method ( For Loop ).

Get the Source Code of this tutorial at

our Social Media Pages

#CppProgramming #ExampleProgram
Рекомендации по теме
Комментарии
Автор

Thank you sir you explain very well.... my logic is now clear.

Nirajjha
Автор

You could also see it in a different way: since instead of return the value you could see it as this: factorial(n-1) = n * factorial (n-1) so if you keep replacing than you get for factorial 4 this: n*n*n*n*factorial

Timo-Epis
Автор

hi can u do this?

create a program that asks the user which application to
perform: Factorial or Triangle. (Note that there will be two applications in one
program.)
After choosing from factorial or triangle, the program should then ask again the user
for a positive integer.
The program then performs the said application: factorial or triangle.
Moreover, it should print and extracts the generation of the factorial or triangle

sadstats
Автор

With argument and with return values for using the factorial in c++ program please fast post me anna

vaishnavi.p