Thats all in title.
In simple i had write this.
#include <iostream>
using namespace std;
int main()
{
int a,i;
cout<<"Enter a number: ";
cin>>a;
for (i=2;i<=a/2;i++)
{
if (a%i==0)
{
cout<<"Its not Prime Number.";
system ("pause");
return 0;
}
}
cout<<"Its a Prime number.";
system ("pause");
}
The main thing is WITHOUT using loop and with recursive function.
Here’s a recursive primality test function:
Use it like: