Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions factorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream> //include basic library
using namespace std;


int factorial(unsigned int n) //function to return int type data ie factorial
{
if (n == 0) //base case
return 1;
return n * factorial(n - 1); //recursive call
}


int main() //main function
{
int num = 5; //any arbitrary example
cout << "Factorial of " << num << " is " << factorial(num) << endl; //printing the OUTPUT
return 0;
}
//end of code
//~By: AMRIT OHRI