fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool czy_pierwsza(int n) {
  5. int d=2;
  6. while (d*d<=n) {
  7. if (n%d==0) return false;
  8. d+=1;
  9. }
  10. return true;
  11. }
  12. int pierwsza(int n) {
  13. int numer =0;
  14. int i=2;
  15. while (numer !=n) {
  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. return 0;
  24. }
  25.  
  26.  
  27.  
  28.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
17 97