fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isP(int n) { for(int i = 2; i * i <= n; ++i) if(n % i == 0) return false; return true; }
  5.  
  6. bool div(int n) { cout << n << endl; char sl[10]; cin >> sl; return sl[0] == 'y' || sl[0] == 'Y'; }
  7.  
  8. int H = 100;
  9.  
  10. int main() {
  11. int c = 0;
  12. for(int a = 2; a <= H / 2 && c < 2; ++a)
  13. if(isP(a))
  14. if(div(a)) {
  15. ++c;
  16. if(a * a <= H && div(a * a)) ++c;
  17. }
  18. cout << (c >= 2 ? "composite" : "prime") << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
prime