Please give some hint

please give some hint for this problem, have seen the editorial but not able to understand it

hi @agarwalarjit.agarwal you have seen the editorial, where are you stuck? Is there anything in particular you are not able to understand?

yeah, i am not able to understand that school mathematics how to do that in code

@agarwalarjit.agarwal editorial contains the code as well. You will find the code for big factorials on GFG as well, you can check out the implementation part from there.

i do not want to copy code, it will be better if you explain me the logic, i will then try to implement it myself

@agarwalarjit.agarwal
to perform arithmetics, you can create a really large array (check the number of digits present in 100! on the internet and make array size accordingly). initialise array with 0, and keep a variable to keep track of the size of the array we are actually using. LIke if we have stored {6} then we are using only “1” place in reality, not the whole array.
To ease the implementation, its better to store the number in reverse order. ie if number is 120, store it as {0, 2, 1} (because array is growing from left to right so we store the number such that number also grows in that direction. it is easy to add an extra digit to the right, instead of left in an array).
so now, you can keep a variable called carry.
for each digit of the array a, if you are multiplying it by the number “n”, then
a[i] = ((a[i]* n) + carry) % 10 and carry = ((a[i]* n) + carry) / 10
after you have processed all the digits, add on additonal digits, till carry = 0

example
arr = {4,2,0,0,0....}
now, len = 2 (ie, number is 24), lets say we are multiplying it by 5. initially, carry = 0
a[0] = (4*5 + 0) % 10 = 20 % 10 = 0
carry = 20/10 = 2
a[1] = (2*5 + 2) % 10 = 12 % 10 = 2
carry = 12/10 = 1
now len = 2, and array is {0, 2, 0, 0, 0…} but carry is not 0, so we need to do some more work
we will increase length by 1, and arr[i2 = carry % 10 = 1, now divide carry by 10 and keep on doing this till carry reaches 0. (this can be done by a simple while loop)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.