I defined a function by:
input : two numbers l,k
output: the number k in base l
Code:-
def base(k,l):
result=''
while k!=0:
remainder = k%l
k=k//l
result= result + str(remainder)
return result
The Problem occurs when the numbers are divisible by any power of the base.
For ex:- If base = 2 and k = 2, the output is 01 instead of 10. The same happens in some other numbers as well
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…