Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int isPrime(long);
- int main(){
- long c,t=3;
- for(c=1;c<=10001;t+=2)if(isPrime(t))c++;
- printf("%d\n", t);
- return 0;
- }
- int isPrime(long x){
- int i;
- if(x==2||x==3) return 1; //if i = 2 or 3, return true
- if(!(x&1)) return 0; //if x is even return false
- //if x is divisible by i return false
- for(i=3;i<=sqrt(x);i+=2)if (x%i == 0) return 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement