I made this program to familiarize myself with recursion and for all intents and purposes it is working.
def alpha_covert(to_print):
if to_print is 0:
return 'Z'
else:
return chr(int(to_print) + 64)
def order(to_print):
if to_print <= 26:
return alpha_covert(to_print)
else:
return (str(order(to_print % 26))) + (str(order(to_print / 26)))
Some example outputs:
>>print(order(1))
>>print(order(100))
>>print(order(443))
>>print(order(9001))
>>print(order(9999999999999999))
A
VC
AQ
EHM
O@JIHYHMTURB
For the last output why is there a @
? I assumed there was no issue as int
isn't declared until I use alpha_covert
which by then should only be less than or equal to 26
.
Is this some kind of float rounding error?
Some additional samples while I'm trying to self-solve this. I don't know what this means:
>>print(order(9999999999999997))
>>print(order(9999999999999998))
>>print(order(9999999999999999))
M@JIHYHMTURB
N@JIHYHMTURB
O@JIHYHMTURB