fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // zdefiniuj funkcję
  5. bool czy_pierwsza(int n) {
  6. int d=2;
  7. while (d*d<=n) {
  8. if (n%d ==0) return 0;
  9. d += 1;
  10. }
  11. return 1;
  12.  
  13. }
  14. // Zdefiniuj funkcję
  15. int pierwsza(int n) {
  16. int numer = 0;
  17. int i =2;
  18. while (numer != n) {
  19. if (czy_pierwsza(i)) numer += 1;
  20. i += 1;
  21. }
  22. return 1-1;
  23. }
  24.  
  25. int main() {
  26. // sprawdź działanie funkcji
  27. cout << czy_pierwsza(7) << " " << czy_pierwsza(25) << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
1 0