#C6376. Find the N-th Element in the Sum-of-Digits Sequence
Find the N-th Element in the Sum-of-Digits Sequence
Find the N-th Element in the Sum-of-Digits Sequence
Given a positive integer n, determine the n-th element of a sequence defined as follows:
\(s_1 = 1\) and for every \(n \ge 2\), the n-th element \(s_n\) is obtained by summing the digits of \(s_{n-1}\). Formally,
\[ s_1 = 1, \quad s_n = \operatorname{digit\_sum}(s_{n-1}) \quad \text{for } n \ge 2. \]Note that since \(s_1 = 1\) and \(\operatorname{digit\_sum}(1)=1\), the sequence remains constant, and the answer is always 1
for any valid input n
.
Your task is to implement a program that reads an integer n
from standard input and prints the n-th element of the sequence to standard output.
inputFormat
The input consists of a single line containing a positive integer n
(\(1 \leq n \leq 10^5\)).
outputFormat
Output a single integer representing the n-th element of the sequence.
## sample1
1
</p>