fork(2) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. bool simple(int n)
  5. {
  6. int tmp = sqrt(n);
  7. for (int i = 2; i <= tmp; ++i) {
  8. if (!(n % i)) return true;
  9. }
  10. return false;
  11. }
  12. bool h_simple(int n)
  13. {
  14. while (n != 0) {
  15. if (simple(n)) return false;
  16. n /= 10;
  17. }
  18. return true;
  19. }
  20. int main()
  21. {
  22. int val = 733;
  23. h_simple(val) ? cout << val << " is hyper simple" : cout << val << " false";
  24. }
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
733 is hyper simple