Skip to content

Commit f217f88

Browse files
committed
Added: Factorial of a Number in C++
1 parent f7acafa commit f217f88

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

cpp/Nfactorial.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
using namespace std;
3+
int fac(int n){
4+
if(n==1){
5+
return 1;
6+
}
7+
return n*fac(n-1);
8+
}
9+
int main(){
10+
int n;
11+
cout<<"Enter the value of N : ";
12+
cin>>n;
13+
cout<<"Result is : "<<fac(n);
14+
}

0 commit comments

Comments
 (0)