serie de primos en c

Solutions on MaxInterview for serie de primos en c by the best coders in the world

showing results for - "serie de primos en c"
Luigi
15 Sep 2020
1#include <stdio.h>
2
3int main(){
4    int n,k;
5    int i;
6    do{
7        printf("Enter a value until you want to show primes: ");
8        scanf("%d",&n);
9    }while(n<=0);
10
11
12    for(i=1;i<=n;i++){
13        for(k=2;k<i,i%k;k++){
14            if(k>i/2){
15                printf("%d, ",i);
16                break;
17            }
18        }
19    }
20
21
22    return 0;
23}