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