Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- main (){
- int j;
- int primecnt;
- int primes[20];
- primecnt=1;
- primes[0]=2;
- int cand=3;
- while (primecnt < 20){
- for (j=0; j<primecnt; j++){
- if (cand % primes[j] == 0){
- goto notprime;
- }
- }
- primes[primecnt]=cand;
- primecnt += 1;
- notprime:
- cand += 2;
- }
- for (j=0; j<primecnt; j++){
- printf("%d\n", primes[j]);
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement