Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- bool esPrimo(int n) {
- if(n==1) return 0;
- if(n<4) return 1;
- if(n%2==0) return 0;
- if(n<9) return 1;
- if(n%3==0) return 0;
- else {
- for(int j=1;j*j<=n;j+=6){
- if(n%j==0) return 0;
- if(n%(j+2)==0) return 0;
- }
- return 1;
- }
- }
- int main() {
- int ret=0;
- int count=0;
- for(int j=1;;j++){
- if(esPrimo(j)) {
- cout << j << " es primo" << endl;
- count++;
- if(count==10001) {ret=j;break;}
- }
- }
- cout<< "Return: " << ret << endl;
- }
Add Comment
Please, Sign In to add comment