From ffea1f3c9bf635f11959cfd82564e5a66ae2753b Mon Sep 17 00:00:00 2001 From: Mohit Jangid Date: Fri, 15 Oct 2021 17:15:32 +0530 Subject: [PATCH] Code to find factorial of large Numbers --- C++/LargeNumberFactorial.cpp | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 C++/LargeNumberFactorial.cpp diff --git a/C++/LargeNumberFactorial.cpp b/C++/LargeNumberFactorial.cpp new file mode 100644 index 0000000..2cdc992 --- /dev/null +++ b/C++/LargeNumberFactorial.cpp @@ -0,0 +1,64 @@ +#include +using namespace std; +int main() +{ + int num; + cin>>num; + int arr[100000] = {0}; //array to store digits of factorial + + arr[0] = 1; //initializing 0th element as 1 because it is going to store unit digit + + int remainingNum = 0; //variable to store carry or other/remaining digit after storing unit digit in array at 0th position after multiplying it with number + + int lengthOfFactorial = 1; + + int number = 2; //factorial will start by 2 onwards and from 3,4,5,6......to N + + int position = 0; //variable to store position of digits which are to be stored in array + + while(number<=num){ + + position = 0; + remainingNum = 0; + while(position=0) + { + cout<