問題一覧 > 通常問題

No.713 Sum of Primes

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 384
作問者 : makonagix / テスター : ミドリムシ
お気に入りにしたユーザー ProblemId : 1878 / 自分の提出
問題文最終更新日: 2026-06-25 06:04: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 195 (順位表) の他の問題:

Problem Statement

Nama-kun studied prime numbers at school.
A prime number is a number that has no divisors other than 1 and itself. However, 1 is not a prime number. For example, 2, 3, 5, 7, 11, 13, ... are prime numbers.
Nama-kun could not find any regularity in the prime numbers themselves, but he wondered whether there might be some regularity in the sums of prime numbers.
Write a program that outputs the sum of all prime numbers less than or equal to $N$ ($1≦N≦1000$).

Input

$N$


An integer $N$ ($1≦N≦1000$) is given.

Output

Output the sum of all prime numbers less than or equal to $N$.
Print a newline at the end.

Sample

Sample 1
Input
7
Output
17

The prime numbers less than or equal to $7$ are $2$, $3$, $5$, $7$, so you should output $2+3+5+7=17$.

Sample 2
Input
12
Output
28

$N$ is not necessarily a prime number.

Sample 3
Input
334
Output
9854

The number $334$ has no particular meaning. That's a lie.

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