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