#include<iostream.h>
void main ()
{
long num, fact; int count;
cout << "ENTER A NUMBER : ";
cin >> num;
for ( fact=1, count=0; fact<=num/2; fact=fact+1)
{
if (num%fact==0)
count=count+1;
}
if (count==1)
cout << "\nYES! IT IS A PRIME NUMBER." << endl;
else
cout << "\nNO! IT IS NOT A PRIME NUMBER." << endl;
}
No comments:
Post a Comment