Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int delime(int delitel, int delenec) {
- if((delenec%delitel) == 0)
- return 1;
- else
- return 0;
- }
- int main(void)
- {
- int cislo, exitStatus, kurzor;
- float odmocnina;
- printf("Enter your integer: ");
- exitStatus = scanf("%d", &cislo);
- if(exitStatus == 1) {
- if (cislo <= 0) {
- printf("It seems you have entered too big number!\n");
- return 1;
- }
- }
- else {
- printf("You should enter number!\n");
- return 1;
- }
- if (cislo == 1) {
- printf("1 is not prime number.\n");
- return 0;
- }
- if (cislo == 2) {
- printf("2 is prime number.\n");
- return 0;
- }
- if(delime(2, cislo)) {
- printf("%d is not prime number!\n", cislo);
- return 0;
- }
- odmocnina = sqrtf(cislo);
- kurzor = 3;
- while(kurzor <= odmocnina) {
- if(delime(kurzor, cislo)) {
- printf("%d is not prime number!\n", cislo);
- return 0;
- }
- kurzor = kurzor + 2;
- }
- printf("%d is prime number!\n", cislo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement