Guest User

Untitled

a guest
Feb 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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,nombre,division; // i = valeur qui verifie, nombre = tous les nombres a tester
  8.  
  9.  
  10. do
  11. {
  12. printf("Entrez un nombre positif comme limite: ");
  13. scanf("%d",&limite);
  14. }while (limite<1);
  15. nombre=2;
  16.  
  17. while (nombre<limite)
  18. {
  19. i=2;
  20. division=0;
  21. while ((i<nombre)&&(division==0))
  22. {
  23. if (nombre%i==0)
  24. {
  25. division=1;
  26. }
  27.  
  28. i++;
  29. }
  30.  
  31. if (division==0)
  32. {
  33. printf("\n%d est premier",nombre);
  34. }
  35.  
  36. nombre++;
  37. }
  38.  
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment