blob: 81241a7141a5989e0d375a0cf5fff529f69ef41c (
plain)
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
|
#include<iostream>
bool estpremier ( int n) {
int cpt=2;
bool trouve= false;
while ( !trouve && cpt <= n/2 ) {
if ( n % cpt == 0) {
trouve = true;
}
cpt ++;
}
return !trouve;
}
int prochainpremier ( int n) {
while ( !estpremier(n)) {
n++;
}
return n;
}
int main () {
int n=0;
std::cin>>n;
std::cout << n << " prochain premier " << prochainpremier(n)<<std::endl;
return 0;
}
|