Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int x,isprime=1;
- scanf("%d",&x);
- if(x==1 || x==2){printf("Prime Number %d",x);}
- else if(x>2)
- {
- int div;
- for(div=3;div<x;div=div+2)
- {
- if (x%div!=0)
- {isprime=1;}
- else {
- isprime=0;
- printf("Not Prime %d",x);
- break;
- }
- }
- }
- if(isprime==1 && x!=1 && x!=2){printf("%d is PRIME",x);}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement