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) return false;
  7. d+=1;
  8. }
  9. return true;
  10. }
  11. int pierwsza(int n) {
  12. int numer =0;
  13. int i=2;
  14. while (numer != n) {
  15. if (czy_pierwsza(i)) numer += 1;
  16. i += 1;
  17. }
  18. return i-1;
  19. }
  20. int main() {
  21. cout << pierwsza(7) << " " << pierwsza(25) << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
11 73