Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int ePrim(int n)
- {
- if(n < 2)
- return 0;
- if(n == 2)
- return 1;
- if(n % 2 == 0)
- return 0;
- int radical = sqrt(n);
- for(int d = 3; d <= radical; d += 2)
- if(n % d == 0)
- return 0;
- return 1;
- }
- int main(){
- int n;
- cin >> n;
- cout << ePrim(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement