No.713 Sum of Primes
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
makonagix