From e04eb8cae8a773407a0aa012639178631d0e2600 Mon Sep 17 00:00:00 2001 From: AmritOhri <50171211+AmritOhri@users.noreply.github.com> Date: Wed, 9 Oct 2019 17:47:20 +0530 Subject: [PATCH] Create factorial.md --- factorial.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 factorial.md diff --git a/factorial.md b/factorial.md new file mode 100644 index 0000000..a2620da --- /dev/null +++ b/factorial.md @@ -0,0 +1,20 @@ +#include //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