Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. int pierwsza(int x)
  6. {
  7. int j;
  8. for(j=0;j<=x;j++)
  9. {
  10. if(x%j==0)
  11. {
  12. return 0;
  13. }
  14. }
  15. return 1;
  16. }
  17.  
  18.  
  19. void liczby_pierwsze()
  20. {
  21. int a, b, i ;
  22.  
  23. printf("Podaj 2 liczby\n");
  24. scanf("%d",&a);
  25. scanf("%d",&b);
  26.  
  27. if(b>a)
  28. {
  29. for(i=a;i<=b;++i)
  30. {
  31. if(pierwsza(i)==1)
  32. {
  33. printf("%d\n",i);
  34. }
  35. }
  36. }
  37. else
  38. printf("Pierwsza liczba musi byc mniejsza od drugiej\n");
  39.  
  40. }
  41.  
  42.  
  43. int main(int argc, char *argv[]) {
  44. liczby_pierwsze();
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement