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.  
  16. if (czy_pierwsza(i)) numer += 1;
  17. i +=1;
  18. }
  19. return i-1;
  20. }
  21. int main() {
  22. cout<<pierwsza(7)<<" "<<pierwsza(25)<<endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
17 97