From eb12e1f786e7343e1bcc7225ceb1b4e4769f9666 Mon Sep 17 00:00:00 2001 From: AmritOhri <50171211+AmritOhri@users.noreply.github.com> Date: Wed, 9 Oct 2019 18:09:02 +0530 Subject: [PATCH] Factorial.md Factorial Program #1 --- 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