RE: Computation Contest #9 [2 SBI]

You are viewing a single comment's thread from:

Computation Contest #9 [2 SBI]

in programming •  5 years ago 

I'll share with you a solution that I found in an old exam:
https://github.com/gravlaks/multiplication-recursive/blob/master/multiplication.py

It's a neat recursive solution, but sadly doesn't solve your problem as big numbers lead to "maximum recursion depth error" and computation is slow.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

What you did is just implementing "the intuitive algorithm of simple repeated addition" which I mentioned in the problem which is as you correctly discovered very slow because you need b calls to func1(you could have written there just a+b instead of func1(a,b). Addition is allowed).

You might also want to think about what happens when you use negative numbers.