fork download
  1. #include <iostream>
  2. using namespace std;
  3. bool checkPrime(int x);
  4. int main() {
  5. // your code goes here
  6. int a;
  7. cin>>a;
  8. cout<<checkPrime(a)<<endl;
  9. return 0;
  10. }
  11. bool checkPrime(int x)
  12. {
  13. int composite=0 ,prime=0;
  14. for (int i=2; i<x ; i++)
  15. {
  16. if(x%i==0)
  17. {
  18. composite=1;
  19. break;
  20. }
  21. else
  22. {
  23. prime++;
  24. }
  25. }
  26. if (composite==1)
  27. return false;
  28. else
  29. return true;
  30. }
Success #stdin #stdout 0s 16064KB
stdin
87654321
stdout
0