如何计算素数

时间:2019-04-07 04:03:16

标签: c++

我正在尝试解决编程问题,这个术语称为“ FiPrima”。 “ FiPrima”数字是指直到想要的素族之前的素数之和。

输入格式 第一行是整数n。然后是一个整数x,连续n次。

输出格式 输出n行数。每行必须包含每行的第x个“ FiPrima”编号。

INPUT EXAMPLE

5
1 2 3 4 5

OUTPUT EXAMPLE
2
5
10
17
28

EXPLANATION
The first 5 prime numbers in order are 2, 3, 5, 7 and 13.

So:

The 1st FiPrima number is 2 (2)
The 2nd FiPrima number is 5 (2 + 3)
The 3rd FiPrima number is 10 (2 + 3 + 5)
The 4th FiPrima number is 17 (2 + 3 + 5 + 7)
The 5th FiPrima number is 28 (2 + 3 + 5 + 7 + 13)
CONSTRAINTS
1 ≤ n ≤ 100
1 ≤ x ≤ 100

任何人都可以创建代码吗?

0 个答案:

没有答案
相关问题