Hi. I wanted to make an example of splitting up recursive functions on python because python returns error if the level of a recursive function gets to deep. And somehow got this funny thing that returns the higest power of 2 from 1 to n given n. Don't sure how exactly it happens. Can anyone explain it Mathematically maybe?
def example(n):
if n < 2: return 1
return example(n/2) + example(n/2)
def example2(n):
if n < 2: return 1
return example2(n/4) + example2(n/4) + example2(n/4) + example2(n/4)
print(example(100), example2(100))
# prints 64 64
print(example(1600), example2(1600))
# prints 1024 1024