CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O/Loops

Problem 9: Sum from 1 to N

An integer N is given on one line from standard input. Output the sum of the integers from 1 to N.

Constraints

1 ≤ N ≤ 100000

Input example 1

5

Output example 1

15

Input example 2

1

Output example 2

1

What you'll train

Cover the edge cases

What you get

  • Specify boundary values
  • Show the approach for calculation
  • Convey the input constraints

How to ask the AI

Tell the AI that when N=1, only 1 should be output, and that it should use a method (a loop or a formula) that computes the correct result even when N is very large.

If you ask vaguelyIf you don't convey the boundary values, the AI might overlook the case where N=1 and output 0 or an incorrect sum.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。