fork download
  1. #include <iostream>
  2. using namespace std;
  3. bool czy_pierwsza(int n){
  4. int d = 2;
  5. while (d*d<= n) {
  6. if (n % d == 0) {
  7. cout << "Dzielnikiem liczby" <<n <<"jest np. " <<d << endl;
  8. return 0;
  9. }
  10. d +=1;
  11. }
  12. return 1;
  13. }
  14. int main () {
  15. cout <<"11" << czy_pierwsza (11) << endl;
  16. cout << "71" << czy_pierwsza(71) << endl;
  17. cout << "17391" << czy_pierwsza(17391)<< endl;
  18. cout <<"17389" << czy_pierwsza(17389) << endl;
  19. cout << "14509" << czy_pierwsza(14509) << endl;
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
111
711
17391Dzielnikiem liczby17391jest np. 3
0
173891
14509Dzielnikiem liczby14509jest np. 11
0