N prime numbers starting with K
#include <iostream>
#include <cmath>
using namespace Std;
This function determines whether a number is a prime
int Sushu (int a)
... {
To determine whether a is four, if a is 4, the direct judgment is not a prime, this method is to solve the problem of this algorithm.
if (a==4)
return 1;
The judging process, starting from 2 to divide, until the number of the prescribed number
for (int i=2;i<sqrt (a); i++)
... {
The process of dividing and taking surplus
if (a%i==0)
... {
return 1;
}
}
return 0;
}
int main ()
... {
Defines two variables, num primes starting with First_num
int First_num,
Num
cout<< "Intput first_num" <<endl
<< "num" <<endl;
cin>>first_num>>num;
Define a variable count as the counter.
int count=0;
Whenever a prime number appears, the counter count plus one
for (first_num+=1;count<num;first_num++)
... {
int B=sushu (first_num);
if (b==0)
... {
cout<<first_num<<endl;
count++;
}
}
return 0;
}