Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- int limite,i,nbr, Divisible; // i = valeur qui verifie, nbr= tous les nombres a tester
- do
- {
- printf("Entrez un nombre positif comme limite:");
- scanf("%d",&limite);
- }while (limite<1);
- nbr=2;
- while (nbr<limite)
- {
- i=2;
- Divisible=0;
- while ((i<nbr)&&(Divisible==0))
- {
- if (!(nbr%i))
- {
- Divisible=1; // nbr divisible par i
- }
- i++;
- }
- if (Divisible==0)
- {
- printf("\n%d est premier\n",nbr);
- }
- nbr++;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment