0% found this document useful (0 votes)
32 views

Factorial Using Recursion

Uploaded by

Abdul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Factorial Using Recursion

Uploaded by

Abdul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

using namespace std;


//recurcive way to find factorial of number
//int factorial(int n)
//{
// if(n==0)
// {
// return 1;
// }
// int fact=1;
// fact=n*factorial(n-1);
// return fact;
//}
//int main()
//{
// cout<<factorial(5)<<endl;
//}
//itrative way to find factorial
int main()
{
int i, n,fact;
fact=1;
cout<<"Enter number "<<endl;
cin>>n;
for(i=n;i>0;i--)
{
fact=fact*i;
}
cout<<fact;
}

You might also like