Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- bool isPrime(int n) {
- int count = 0;
- for(int i=1; i*i <= n; i++) {
- if(n%i == 0) {
- if(i*i == n) count++;
- else count += 2;
- }
- }
- if(count == 2) return true;
- else return false;
- }
- int main() {
- cout << isPrime(12);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement