Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int ePrim(int n)
  6. {
  7. if(n < 2)
  8. return 0;
  9. if(n == 2)
  10. return 1;
  11. if(n % 2 == 0)
  12. return 0;
  13. int radical = sqrt(n);
  14. for(int d = 3; d <= radical; d += 2)
  15. if(n % d == 0)
  16. return 0;
  17. return 1;
  18. }
  19.  
  20.  
  21.  
  22. int main(){
  23.  
  24. int n;
  25. cin >> n;
  26. cout << ePrim(n);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement