#include<stdio.h>
#include<conio.h>
void main()
{
int num,n;
int prime(int);
clrscr();
printf("Enter a number to check prime or not ");
scanf("%d",&num);
n=prime(num);
if(n==0)
{
printf("Not prime");
}
else
if((n!=0)||(n<0)||(n>0))
{
printf("Prime");
}
getch();
}
prime(int num)
{
static int x=2;
if((x==num/2) || (num%x==0))
return num%x;
else
{
x=x+1;
return prime(num);
}
}
#include<conio.h>
void main()
{
int num,n;
int prime(int);
clrscr();
printf("Enter a number to check prime or not ");
scanf("%d",&num);
n=prime(num);
if(n==0)
{
printf("Not prime");
}
else
if((n!=0)||(n<0)||(n>0))
{
printf("Prime");
}
getch();
}
prime(int num)
{
static int x=2;
if((x==num/2) || (num%x==0))
return num%x;
else
{
x=x+1;
return prime(num);
}
}
No comments:
Post a Comment