問題
翻訳を表示A prime is an integer greater than 1 divisible only by 1 and itself. Add every prime strictly smaller than limit. The limit itself is excluded even when it is prime.
Implement prime_sum(limit).
Input
limit: The exclusive upper bound.
Output
Return the sum of the eligible primes, or 0 when none exist.
制約
0 ≤ limit ≤ 2,000,000. Return the sum using a signed 64-bit integer.
例
例 1
入力:
limit = 12
期待される出力:
expected = 28
入力:
long long limit = 12;
期待される出力:
long long expected = 28;
入力:
long limit = 12;
期待される出力:
long expected = 28;
解説
The primes below 12 are 2, 3, 5, 7, and 11; their sum is 28.
例 2
入力:
limit = 2
期待される出力:
expected = 0
入力:
long long limit = 2;
期待される出力:
long long expected = 0;
入力:
long limit = 2;
期待される出力:
long expected = 0;
解説
There are no primes strictly below 2.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。