#include<iostream>
using namespace std;
void prime(int x, int y) { if (x <= 1) x = 2; if (y <= 1) return; for (int i = x; i <= y; i++) { bool flag = true; for (int j = 2; j <= sqrt(i); j++) { if (i%j == 0) flag = false; } if (flag == false) continue; else cout << i << ' '; } cout << endl;
}
int main() { int x,y; cout << "Input the begin and end:"; cin >> x >> y;
prime(x,y);
return 0;
} |
|