Created
November 6, 2018 16:05
-
-
Save thiagodeschamps/88b317b67db597b4942211f1ecddb4fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int ehprimo(int); | |
int main(void){ | |
FILE *fp; | |
fp = fopen("testefileC.txt", "w"); | |
int i = 0; | |
int qnt = 200000; | |
int num = 2; | |
while(i != qnt){ | |
if(ehprimo(num)){ | |
fprintf(fp, "%d\n", num); | |
i++; | |
} | |
num++; | |
} | |
fclose(fp); | |
} | |
int ehprimo(int x){ | |
int i; | |
for(i = 2; i < x/2+1; i++){ | |
if((x % i) == 0){ | |
return 0; | |
} | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment