From 70e9379981410dcf1af084a8957d2859da732bd7 Mon Sep 17 00:00:00 2001 From: Kiran1810 Date: Fri, 4 Aug 2023 23:04:53 +0530 Subject: [PATCH] solved factorial using the while loop in C++ language --- algorithms/CPlusPlus/Maths/factorial.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/algorithms/CPlusPlus/Maths/factorial.cpp b/algorithms/CPlusPlus/Maths/factorial.cpp index a97f98c1..34ab73d1 100644 --- a/algorithms/CPlusPlus/Maths/factorial.cpp +++ b/algorithms/CPlusPlus/Maths/factorial.cpp @@ -30,7 +30,7 @@ int main() { cin>>n; cout<<"factorial is: "<>m; + int factorial = 1; + int j = 1; + while (j <= m) { + factorial = factorial * j; + j++; + } + cout << "factorial of the given number is :" <