Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CZY LICZBA JEST PIERWSZA BEZ MNOZENIA, DZIELENIA I RESZTY
- // ALEKSANDER SZEWCZAK
- #include <stdio.h>
- int main(void)
- {
- int x, p, y, z, c;
- printf("Wpisz liczbe, zeby zobaczyc czy jest pierwsza:\n");
- scanf("%d", &x);
- y = x;
- c = x;
- if(x == 2 || x == 3 || x == 5)
- {
- printf("\nTAK, JEST PIERWSZA");
- }
- else
- {
- while(y > 0) y-=2;
- if(y == 0) z = 0;
- else z = 1;
- while(c > 0) c-=5;;
- if(c == 0) z = 0;
- else z = 1;
- if(z == 0 || x == 1) printf("\nNIE, NIE JEST PIERWSZA"); // dla parzystych
- else // dla nieparzystych
- {
- while(x > 0) x-=3;
- if(x == 0) printf("\nNIE, NIE JEST PIERWSZA");
- else printf("\nTAK, JEST PIERWSZA");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement