Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main() {
- int x,y,primo=1,num;
- printf("Digite um numero: ");
- scanf("%d",&num);
- printf("\nOs numeros primos menores que %d sao:\n\n",num);
- printf("2 ");
- for(x=3; x < num; x+=2) {
- primo=1;
- for(y=3; y <= ((x/2)-1); y+=2) {
- if(!(x%y) && x!=y) {
- primo=0;
- break;
- }
- }
- if(primo) printf("%d ",x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement