We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

logic : -
suppose you're asked to multiply 25 with 24..

what toddlers do..

25

* 24

100

50 *

600

what we do...
5*24=120, 0 stays, carry 12... then 2*24+12=60.. hence 600.
this method is called supercarry.
Take an array, use this supercarry method and for every i, print a digit in array[i]. then print the anti-array.
If there are extra zeroes in front of the answer, remove them by using..

for (i = len; i >= 0; i--)
if (a[i] != 0) {
neww = i;
break;
}
for (i = neww; i >= 0; i--)
printf("%d", a[i]);

Can you explain how i <= len + 1 is working correctly? When I try to multiply two numbers (1050 * 1049) using your code, it's producing wrong results, it's missing some digits.

## Extra Long Factorials

You are viewing a single comment's thread. Return to all comments →

solution of this code in c...

logic : - suppose you're asked to multiply 25 with 24..

what toddlers do..

## * 24

100

50 *

600

what we do... 5*24=120, 0 stays, carry 12... then 2*24+12=60.. hence 600. this method is called supercarry. Take an array, use this supercarry method and for every i, print a digit in array[i]. then print the anti-array. If there are extra zeroes in front of the answer, remove them by using..

`for (i = len; i >= 0; i--) if (a[i] != 0) { neww = i; break; } for (i = neww; i >= 0; i--) printf("%d", a[i]);`

how your multiplication goes..

n=25.

52 006 00831 006303

etc..

when you print the anti-array

the number prints without any problem...

Can you explain how i <= len + 1 is working correctly? When I try to multiply two numbers (1050 * 1049) using your code, it's producing wrong results, it's missing some digits.

But Factorial is working fine. Can you explain?