23rd Oct 2020, 5:16 AM
Mustafa Tanvir
Mustafa Tanvir - avatar
3 Réponses
+ 5
It recursively transforms the multiplication into a series of additions. The first call to multi is with 5,5, which gets transformed into multi(4,5)+5, which is transformed into multi(3,5)+5+5, etc. In the end we have multi(0, 5)+5+5+5+5+5. Multi(0,5) returns 0 because of the if statement and then all the 5s are added together. So it's a way to transform multiplication into additions.
23rd Oct 2020, 6:11 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Thanks guys for the detailed and we'll explained explanations
23rd Oct 2020, 6:43 AM
Mustafa Tanvir
Mustafa Tanvir - avatar