Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void prime_num(int n)
- {
- int i,prime=0;
- if(n>0&&n!=1)
- {
- for(i=2;i<n;i++)
- {
- if(n%i==0)
- {
- prime=1;
- break;
- }
- }
- if(prime==0)
- {
- printf("%d is a prime number\n",n);
- }
- else
- {
- printf("%d is not a prime number\n",n);
- }
- }
- }
- int main()
- {
- int n;
- scanf("%d",&n);
- prime_num(n);
- return 0;
- }
Add Comment
Please, Sign In to add comment