A cryptography class numbers its practice keys using the first few prime numbers. Given an integer K, the instructor wants the sum of the first K primes (2, 3, 5, 7, 11, ... in increasing order) to use as a checksum.
Line 1: a single integer K.
A single integer: the sum of the first K prime numbers.
Example 1
Input
1
Expected
2
Explanation
The first prime is 2, so the sum is 2.
Example 2
Input
4
Expected
17
Explanation
The first 4 primes are 2, 3, 5, 7, summing to 17.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →