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

Problem 18: Sum of Multiples of 3 or 5

An integer N is given on one line from standard input. Output, on one line, the sum of all integers from 1 to N inclusive that are multiples of 3 or 5.

For example, if N is 10, the qualifying numbers are 3, 5, 6, 9, 10, so the sum is 33.

Constraints

1 ≤ N ≤ 100000

Input example 1

10

Output example 1

33

Input example 2

3

Output example 2

3

What you'll train

State the constraints

What you get

  • Specify the boundaries of the range
  • Explain how to combine conditions
  • Explain how to handle duplicates

How to ask the AI

Clearly tell the AI that the range from 1 to N should include N, and that for the condition "multiples of 3 or 5," numbers satisfying both should not be counted twice.

If you ask vaguelyNumbers that are multiples of both 3 and 5 (multiples of 15) might get added twice.

あなたのコード

実行しました

プレビュー

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

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

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