29 lines
415 B
C
29 lines
415 B
C
#include <stdio.h>
|
|
|
|
#define N 100
|
|
|
|
int divisible(int n, int q){
|
|
return n%q==0;
|
|
}
|
|
|
|
int premier(int n){
|
|
if(n<2)return 0;
|
|
for(int k=2;k*k<=n;k++){
|
|
if(divisible(n,k))
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int main() {
|
|
int n;
|
|
do{
|
|
printf("Quel nombre ? ");
|
|
scanf("%d",&n);
|
|
}while(0>=n || n>=1000);
|
|
|
|
for(int k=2;k<=n;k++)
|
|
if(premier(k))printf("%d, ", k);
|
|
printf("et c'est tout ce que vous m'avez demandé.\n");
|
|
}
|