This function is part of a program to convert numbers between different bases.
num = 32 b1 = 10 b2 = 2 x = 1 def increasex(num,b2,x): if num%(b2**x) < num: x = x+1 increasex(num, b2, x) else: print x return x print increasex(num,b2,x)
The parameters are the number you wish to convert, the base you are converting to, and the value of the exponent (to figure the place, i.e. the 2**x place) . The x value will tell another function where to start dividing, (i.e. 32/2**6, followed by 32/2**5, and so on).
The function will print the value of x, which is 6 with the current values, but will not return x. Why? This is driving me crazy. Any help is greatly appreciated.