問題一覧 > 通常問題

No.1168 Digit Sum Sequence

レベル : / AI推定難易度 : 101 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 604
作問者 : opt / テスター : ningenMe
お気に入りにしたユーザー ProblemId : 4401 / 自分の提出
問題文最終更新日: 2020-12-04 09:44:16
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 261 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$. Define the sequence $(a_i)_{i \geq 1}$ as follows:

  • $a_1 = N,$
  • $a_{i+1} = (a_i$'s sum of digits in decimal notation$) \quad$ $(i \geq 1).$

Find the value of $a_{100}$.

Input

The input is given in the following format:

$N$

  • $N$ is an integer
  • $1 \leq N \leq 10^9$

Output

Output the value of $a_{100}$. Print a newline at the end.

Sample

Sample 1
Input
753
Output
6

The terms of $(a_i)_{i \geq 1}$ are as follows:

  • $a_1 = 753$
  • $a_2 = 7 + 5 + 3 = 15$
  • $a_3 = 1 + 5 = 6$
  • $a_4 = 6$
  • $\ \vdots$
  • $a_{100} = 6$
Therefore, output $6$.

Sample 2
Input
123456789
Output
9

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。