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