Factorial of large number

my code: https://ide.codingblocks.com/s/222007

when I comment out line 18 , it gives correct answer. Otherwise wrong

I think line 18 shouldn’t bear any affect on my answer but it does :frowning:

even on commenting line 18
it is giving segmentation error

have u sent the correct code ?

It gives wrong answer (i’m running it on sublime text)
example : for 100 it gives a 97 digit number but actually 100! contains 158 digits.

when I comment out line 18 it gives correct answer.

try commenting out 38-42 while on CB ide.

from line 18 u are making the fsize same for all the carry position
but according to the algo
multiply(res[ ], x)

  1. Initialize carry as 0.
  2. Do following for i = 0 to res_size – 1 …a) Find value of res[i] * x + carry. Let this value be prod.b) Update res[i] by storing last digit of prod in it.c) Update carry by storing remaining digits in carry.
  3. Put all digits of carry in res[ ] and increase res_size by number of digits in carry

u need to add the carry value in successive position so
line 18 has to be commented in order to obtain correct answer