4 ms·
Even the basic schoolbook algorithms are recursive a * (10*b + c) = 10*(a*b) + (a*c) In fact the usual method is even non-tail recursive, you build up a
by edflsafoiewq 4y ago
Even the basic schoolbook algorithms are recursive
a * (10*b + c)
= 10*(a*b) + (a*c)
In fact the usual method is even non-tail recursive, you build up a (literal!) stack of intermediate results which you sum back up at the end.
- contravariant 4y agoI think most schoolbook algorithms are tail recursive. They're a bit hard to write down otherwise.
- lupire 4y agoThe usual method is iterative: for digit in a, for digit in b, multiply digits and offset by sum of indices of digits. The sun results.