C++ program to find factorial of large numbers using array
In this program basically we multiply the number from 1 to the number and every time we store the value in array from left to right for e.g. ( if I want to store 129 into the array I will store it as 921 it will be easily to do calculations this way).
- Initially 1 will be stored in the ar and the ar_size will also be 1
- then it will enter int the of x from x=2 to x=number multiply x*ar
- and update the ar. To store the value in ar following operation will take place the loop runs from i=0 to ar_size and we will store the last digit int the variable p and update the ar and the rest of the digits will be stored in c and in the next loop we will have to store digit by digit in ar.
Let’s take an example of 5
ar=4, c=2 ar=42,c=0