Guest User

Untitled

a guest
Feb 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. int limite,i,nbr, Divisible; // i = valeur qui verifie, nbr= tous les nombres a tester
  8. do
  9. {
  10. printf("Entrez un nombre positif comme limite:");
  11. scanf("%d",&limite);
  12. }while (limite<1);
  13. nbr=2;
  14.  
  15. while (nbr<limite)
  16. {
  17. i=2;
  18. Divisible=0;
  19. while ((i<nbr)&&(Divisible==0))
  20. {
  21. if (!(nbr%i))
  22. {
  23. Divisible=1; // nbr divisible par i
  24. }
  25.  
  26. i++;
  27. }
  28.  
  29. if (Divisible==0)
  30. {
  31. printf("\n%d est premier\n",nbr);
  32. }
  33.  
  34. nbr++;
  35. }
  36.  
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment