Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int i;
- for (i = 2; i <= n; ++i) {
- bool isPrime = true;
- int j;
- for (j = 2; j < i; ++j)
- if (i % j == 0)
- isPrime = false;
- if (isPrime)
- cout << i << " is prime" << endl;
- else
- cout << i << " is composite" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement