An integer N is given on a single line from standard input. Output, on one line, the sum of the digits of N.
For example, if N is 123, then 1 + 2 + 3 = 6, so output 6.
Constraints
1 ≤ N ≤ 1000000000
Input example 1
123Output example 1
6Input example 2
9Output example 2
9What you'll train
Specify the input
What you get
How to ask the AI
Tell the AI that N is given as an integer and needs to be broken down into its digits before summing them. It's also reassuring to confirm that the program works correctly even when N has only one digit, or when it has many digits.
If you ask vaguelyThe AI may confuse extracting digits from the integer directly with converting it to a string, resulting in an implementation where the digit-splitting method is left ambiguous.
あなたのコード
プレビュー
AIレビュー(プロンプト練習)
コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。