Find prime numbers?

I need your help in this program, this would very important for me. Find the first 10 prime numbers, which the following formula applies:

prime + 10 = prime number

prime + 14 = prime number

(prime)² + 2 = prime number

So to make the task cleaner,the first prime number will be the 3,because

3+10 = 13 (13 is a prime number)

3+14 = 17 (17 is a prime number)

3²+2 = 11 (11 is a prime number)

I have no idea,how should I make these statements in the program. I've done it so far. The "2" is missing, but I think its not problem, because it won't be in any of these condition.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>

using namespace std;

int main() {

int num, i,counter=0;

cout << endl << "The first 10 prime numbers are : " << endl;

for(num = 2; num <= 100000; num++) {

    for(i = 2; i <= (num / 2); i++) {

        if(num % i == 0) {
            i = num;
            break;
        }
    }

    if(i != num) {
        counter=counter + 1;
        cout << num << " ";
    }
     if(counter > 9)
    {
        system("pause");
    }



    }

}
Last edited on
Although 3 may be the first number satisying your conditions, the next number appears to be well above a hundred million, which does not bode well for your quest for ten of them.
@klausskent
First, get your own thread. It is really, really friggin’ rude to hijack someone else’s. (We will be nice to you if you do that.)

@Obit055
What level course is this?
What is its name?

I think you have likely misunderstood something about the assignment...
Topic archived. No new replies allowed.