Hey,
I came up with following solution:
def decimalToBinary(testVariable):
if testVariable == 1: return '1'
return decimalToBinary(testVariable//2) + str(testVariable%2)
Editor gives a “recursion depth exceeded” error. Up on checking edu’s solution, I found an extra recursive call with testVariable%2.
Intuitively, I feel edu’s solution takes more recursive calls to get to solution, hence occupying more space on recursive stack; but for some reason this solution is accepted.
Just curious on why a function with more recursive calls went through than my solution.
Course: https://www.educative.io/courses/recursion-in-python
Lesson: https://www.educative.io/courses/recursion-in-python/YMR2yRMkRGW