//Hi all,can you explain how to call this function in main.
//i ask user to enter the number,like this is it correct in main,recursevely call function?
bool isPrime(int n, int d);
int main()
{
int number;
cout <<"Enter number >= 1";
cin >> number;
if(isPrime(number))
{
return
cout << "Yes";
else
return
cout << "No";
}
return 0;
}
bool isPrime(int n, int d)
{
if(n<2)
return 0;
if(d == 1)
return true;
else
{
if(n % d == 0)
return false;
else
return isPrime(n, d - 1);
}
}
aluhnev 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.