I wrote this program using recursion. I know what I did for the most part, but I am not clear on when it returns true. The program runs alright and does what its supposed to do. But I didnt set any boundary on k so I am wondering when it breaks out and returns true. If k didnt break then the program wouldnt display the correct answer. Does it break when k =nv? If so, why? Thanks for the help.Code:// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <iostream>
#using <mscorlib.dll>
using namespace System;
using namespace std;
bool checkprime(int, int);
int k=3;
int _tmain()
{
int n;
cout << "Input Number: "; cin >> n;
if(checkprime(n,k))
cout << "Yes"<<endl;
else
cout << "no" <<endl;
return 0;
}
bool checkprime(int nv, int kv) {
if (nv%2 ==0)
return false;
if (nv %k ==0){
return false;
checkprime(nv, k+1);
}
else
return true;
}