Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int main()
- {
- int n1, n2, i, cont = 0, j, primos = 0;
- printf("Digite n1 e n2:\n");
- scanf("%d %d", &n1, &n2);
- while(n1 != 0 && n2 != 0)
- {
- while(n1 <= n2)
- {
- j = 1;
- while(j <= n1)
- {
- if(n1 % j == 0)
- cont++;
- j++;
- }
- if(cont <= 2)
- primos++;
- cont = 0;
- n1++;
- }
- printf("%d primos entre n1 e n2.\n", primos);
- primos = 0;
- printf("Digite n1 e n2:\n");
- scanf("%d %d", &n1, &n2);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment