Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- int main() {
- unsigned int a, b;
- std::cin >> a >> b;
- if (a > b) {
- std::cout << "Invalid input.";
- }
- for (int i = a; i <= b; i++) {
- bool isPrime = true;
- int SqrtOfI = sqrt(i);
- for (int k = 2; k <= SqrtOfI; k++) {
- if (i % k == 0) {
- isPrime = false;
- }
- }
- if (isPrime&&i!=1) {
- std::cout << i << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement