fork download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. bool prime(int n)
  6. {
  7. for(int i=2;i*i<n;i++)
  8. {
  9. if(n%i==0)
  10. return false;
  11. }
  12.  
  13. return true;
  14. }
  15.  
  16.  
  17. int main() {
  18.  
  19. int n;
  20. cin>>n;
  21.  
  22. if(prime(n))
  23. cout<<"prime";
  24. else cout<<"not prime";
  25. // your code goes here
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5588KB
stdin
8646757
stdout
not prime