First of all, your code. It’s ugly. Please use more whitespace and commenting. It takes a while to figure out what certain variables represent.
With that in mind I think you need to separate your for
and while
loops that are inside your for(j = 0; j < m; j++)
loop. The while
loop should not be in the for
loop:
for(j = 0;j < m; j++)
{
x= a[j] * (i+temp);
a[j] = x%10;
temp = x/10;
}
while(temp != 0)
{
a[m] = temp%10;
temp /= 10;
m++;
}
^ Do that instead.
solved Logical error in finding 100 factorial [closed]