-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d8dd6e
commit 98eaf53
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Created by Riya Pannu on 15/10/17. | ||
|
||
#include<iostream> | ||
using namespace std; | ||
|
||
long long int factorial(long long int n) { | ||
if (n == 0) | ||
return 1; | ||
else | ||
return n * factorial(n-1); | ||
|
||
} | ||
|
||
int main() { | ||
long long int n; | ||
cout<<"Enter a number \n"; | ||
cin >> n; | ||
|
||
long long int result = factorial(n); | ||
cout << "The factorial of "<<n<<" is "<<result << endl; | ||
return 0; | ||
} |