fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool snt(long n)
  5. {
  6. if(n < 2) return 0;
  7. for(int i = 2; 1ll * i * i <= n; i++) if(n % i == 0) return 0;
  8. return 1;
  9. }
  10.  
  11. int main()
  12. {
  13. long p;
  14. for(int u = 1; u <= 11; u++)
  15. {
  16. cin >> p;
  17. cout << snt(p) << '\n';
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 5320KB
stdin
3
7
31
127
2047
8191
131071
524287
8388607
536870911
2147483647
stdout
1
1
1
1
0
1
1
1
0
0
1