백준 2145번: 숫자 놀이 #Python

ColorlessDia·2024년 9월 6일

algorithm/baekjoon

목록 보기
292/808
import sys

while True:
    N = sys.stdin.readline().rstrip()

    if N == '0':
        break
    
    if len(N) == 1:
        print(N)
        continue
    
    while 1 < len(N):
        N = str(sum(map(int, list(N))))

    print(N)

0개의 댓글