Advertisement
cinio97

Untitled

Nov 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int czyPierwsza(int liczba){
  5. int x;
  6. x=2;
  7. while(liczba%x!=0)
  8. x++;
  9. if(x==liczba)
  10. return 1;
  11. else
  12. return 0;
  13. }
  14.  
  15. int main()
  16. {
  17. unsigned long int a = 2,b = 0, liczba = 0;
  18. printf("Podaj duza liczbe: ");
  19. scanf("%ld ", &liczba);
  20. while(a < liczba) {
  21. if(czyPierwsza(a) == 1){
  22. b = liczba % a;
  23. if(czyPierwsza(b) == 1)
  24. printf("\nLiczby pierwsze: %ld, %ld", a, b);
  25. a = 1;
  26. break;
  27. }
  28. a++;
  29. }
  30. if(a != 1)
  31. printf("Liczby pierwsze: brak\n");
  32. return 0;
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement