시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 301 217 198 74.157%

문제

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

  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
W3sicHJvYmxlbV9pZCI6IjIxNDUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMmJcdWM3OTAgXHViMTgwXHVjNzc0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWNkMDhcdWI0ZjFcdWQ1NTlcdWMwZGRcdWM3NzggXHViM2M0XHVhY2I4XHVjNzc0XHViMjk0IFx1YzIyYlx1Yzc5MFx1Yjk3YyBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1YzViNFx1YjI5MFx1YjBhMCBcdWIzYzRcdWFjYjhcdWM3NzRcdWIyOTQgXHVjMjJiXHVjNzkwIFx1Y2M0NVx1Yzc0NCBcdWJjZjRcdWIyZTRcdWFjMDAgXHVhYzA0XHViMmU4XHVkNTVjIFx1YjE4MFx1Yzc3NFx1Yjk3YyBcdWQ1NThcdWIwOTggXHVjMGRkXHVhYzAxXHVkNTc0XHViMGM4XHViMmU0LiBcdWMyMmJcdWM3OTAgXHViMTgwXHVjNzc0XHVjNzU4IFx1YWRkY1x1Y2U1OVx1Yzc0MCBcdWIyZTRc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