fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n, i, count = 0;
  7.  
  8. cout << "Enter a number: ";
  9. cin >> n;
  10.  
  11. for(i = 1; i <= n; i++)
  12. {
  13. if(n % i == 0)
  14. {
  15. count++;
  16. }
  17. }
  18.  
  19. if(count == 2)
  20. {
  21. cout << "The number is prime.";
  22. }
  23. else
  24. {
  25. cout << "The number is not prime.";
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5316KB
stdin
51

stdout
Enter a number: The number is not prime.