💡 Python 3
3진법 뒤집기 [Link]
def solution(n):
result = ''
while n > 0:
n, mod = divmod(n, 3)
result += str(mod)
return int(result, 3)
divmod
를 사용하지 않은 코드
def solution(n):
tmp = ''
while n:
tmp += str(n % 3)
n = n // 3
answer = int(tmp, 3)
return answer