#include<iostream.h>
#include<math.h>
void main()
{
int num,count=2;
double sqnum;
cout<<"enter the number you want to check\n";
cin>>num;
sqnum=sqrt(num);
while(count<=sqnum)
{
if(num%count==0)
{
cout<<"the number you enter is not a prime number\n";
break;
}
else
{
count++;
}
}
if(num%count!=0)
{
cout<<"the number is a prime number\n";
}
}
No comments:
Post a Comment