Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool prime(int num){
- if(num==0 or num==1)
- return 0;
- for (int i=2;i*i<=num;++i){
- if (num%i==0)
- return 0;
- }
- return 1;
- }
- int main() {
- int n;
- while (cin>>n and prime(n)) {
- n++;
- while (not prime(n)) n++;
- cout << n << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment