From 4ae8675c82b93eef276b4eae35c730b0722e83ec Mon Sep 17 00:00:00 2001 From: 9284721673 <72208756+9284721673@users.noreply.github.com> Date: Fri, 2 Oct 2020 11:54:49 +0530 Subject: [PATCH] find factorial Find the factorial of given number --- cpp to find the factorial | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cpp to find the factorial diff --git a/cpp to find the factorial b/cpp to find the factorial new file mode 100644 index 0000000..d18c098 --- /dev/null +++ b/cpp to find the factorial @@ -0,0 +1,19 @@ +#include +using namespace std; + +int main() +{ + unsigned int n; + unsigned long long factorial = 1; + + cout << "Enter a positive integer: "; + cin >> n; + + for(int i = 1; i <=n; ++i) + { + factorial *= i; + } + + cout << "Factorial of " << n << " = " << factorial; + return 0; +}