Advertisement
olekturbo

Untitled

Nov 29th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // CZY LICZBA JEST PIERWSZA BEZ MNOZENIA, DZIELENIA I RESZTY
  2. // ALEKSANDER SZEWCZAK
  3. #include <stdio.h>
  4. int main(void)
  5. {
  6. int x, p, y, z, c;
  7.  
  8. printf("Wpisz liczbe, zeby zobaczyc czy jest pierwsza:\n");
  9. scanf("%d", &x);
  10. y = x;
  11. c = x;
  12.  
  13. if(x == 2 || x == 3 || x == 5)
  14. {
  15. printf("\nTAK, JEST PIERWSZA");
  16. }
  17. else
  18. {
  19. while(y > 0) y-=2;
  20. if(y == 0) z = 0;
  21. else z = 1;
  22. while(c > 0) c-=5;;
  23. if(c == 0) z = 0;
  24. else z = 1;
  25.  
  26. if(z == 0 || x == 1) printf("\nNIE, NIE JEST PIERWSZA"); // dla parzystych
  27. else // dla nieparzystych
  28. {
  29. while(x > 0) x-=3;
  30. if(x == 0) printf("\nNIE, NIE JEST PIERWSZA");
  31. else printf("\nTAK, JEST PIERWSZA");
  32.  
  33. }
  34. }
  35. return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement