시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 443 320 292 74.872%

문제

초등학생인 도겸이는 숫자를 좋아한다. 어느 날 도겸이는 숫자 책을 보다가 간단한 놀이를 하나 생각해냈다. 숫자 놀이의 규칙은 다음과 같다.

  1. 주어진 숫자의 각 자릿수를 더한다.
  2. 결과가 한 자릿수가 될 때 까지 규칙1을 반복한다.

예를들어, 숫자 673에 규칙을 적용해보면 결과는 7이 된다 ; 6 + 7 + 3 = 16, 1 + 6 = 7 

도겸이는 당신과 함께 숫자놀이를 하고싶어한다. 도겸이가 주는 숫자들을 풀어보자.

입력

각 줄에 숫자 N이 주어진다. N은 100,000보다 작은 양의 정수이다. 마지막 입력은 0이며, 0에 대한 결과는 출력하지 않는다.

출력

한 줄에 하나씩 한 자릿수 결과를 출력한다.

예제 입력 1

673
51
1000
99
0

예제 출력 1

7
6
1
9
W3sicHJvYmxlbV9pZCI6IjIxNDUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMmJcdWM3OTAgXHViMTgwXHVjNzc0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWNkMDhcdWI0ZjFcdWQ1NTlcdWMwZGRcdWM3NzggXHViM2M0XHVhY2I4XHVjNzc0XHViMjk0IFx1YzIyYlx1Yzc5MFx1Yjk3YyBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1YzViNFx1YjI5MCBcdWIwYTAgXHViM2M0XHVhY2I4XHVjNzc0XHViMjk0IFx1YzIyYlx1Yzc5MCBcdWNjNDVcdWM3NDQgXHViY2Y0XHViMmU0XHVhYzAwIFx1YWMwNFx1YjJlOFx1ZDU1YyBcdWIxODBcdWM3NzRcdWI5N2MgXHVkNTU4XHViMDk4IFx1YzBkZFx1YWMwMVx1ZDU3NFx1YjBjOFx1YjJlNC4gXHVjMjJiXHVjNzkwIFx1YjE4MFx1Yzc3NFx1Yzc1OCBcdWFkZGNcdWNlNTlcdWM3NDAgXHViMmU0X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