Search

10진수 숫자 원하는 진법으로 변경하기

def convert_ten_to_base(n, base): t = "0123456789ABCDEF" q, r = divmod(n,base) if q == 0: return t[r] else: return convert_ten_to_base(q,base) + t[r] # EX) 10진수 숫자 10 -> 4진법으로 변경 print(convert_ten_to_base(10, 4))
Python
복사