Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- for (int j=2;j<=545;j++){//por definicion el 1 no es primo, se empieza en 2
- int a=0;
- for(int i=1;i<=545;i++)//divide a j entre los números del 1 al 100
- {
- if(j%i==0) // si num1 módulo de i es 0, incrementamos a en 1.
- a++;
- }
- if (a==2){ //si solo tiene dos números divisores entonces es primo y se imprime
- printf("%d\n", j);
- }
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement