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