Python recursive program

Posted by mathboy on Stack Overflow See other posts from Stack Overflow or by mathboy
Published on 2010-05-09T18:38:56Z Indexed on 2010/05/09 18:48 UTC
Read the original article Hit count: 180

Filed under:
|

I'm relatively newcomer on programming as I'm educated a mathematician and have no experience on Python. I would like to know how to solve this problem in Python which appeared as I was studying one maths problem on my own:

Program asks a positive integer m. If m is of the form 2^n-1 it returns T(m)=n*2^{n-1}. Otherwise it writes m to the form 2^n+x, where -1 < x < 2^n, and returns T(m)=T(2^n-1)+x+1+T(x). Finally it outputs the answer.

© Stack Overflow or respective owner

Related posts about python

Related posts about recursion