Non-decimal radices/Convert: Difference between revisions

Content added Content deleted
m (→‎{{header|Python}}: Split long line)
Line 848:
 
=={{header|Python}}==
<lang python>defdigits baseN(num,b):= "0123456789abcdefghijklmnopqrstuvwxyz"
def baseN(num,b):
return (((num == 0) and "0" )
or ( baseN(num // b, b).lstrip("0")
+ "0123456789abcdefghijklmnopqrstuvwxyz"digits[num % b]))
 
# alternatively:
Line 859 ⟶ 860:
while num != 0:
num, d = divmod(num, b)
result += "0123456789abcdefghijklmnopqrstuvwxyz"digits[d]
return result[::-1] # reverse