def seven_num(number):
global sevenNum
ahrt = number//7 # 몫
skajwl = number % 7 # 나머지
sevenNum = str(skajwl) + sevenNum
if ahrt >= 7:
seven_num(ahrt)
else:
sevenNum = str(ahrt) + sevenNum
print(sevenNum)
number = int(input())
sevenNum = ""
seven_num(number)
위를 참조하여 n진수 변환 코드도 작성하였다.
# n진수 변환
def conversion_num(base, digit):
global Num
ahrt = base//digit
skajwl = base % digit
Num = str(skajwl) + Num # 바깥거
if ahrt >= digit:
conversion_num(ahrt, digit)
else:
Num = str(ahrt) + Num
print(Num)
base, digit = map(int, input().split())
Num = ""
conversion_num(base, digit)