I tried so hard to solve this. Please help me in solving this problem.
#include
#include
#include<math.h>
using namespace std;
bool isPrime(int a){
if(a == 1 || a == 0){
return false;
}
if(a == 2){
return true;
}a
for(int i=2;i<=sqrt(a);i++){
if(a % i == 0){
return false;
}
}
return true;
}
int main(){
int n;
cin>>n;
string s;
cin>>s;
int count = 0;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
string temp = “”;
for(int k =i;k<=j;k++){
temp += s[k];
}
if(isPrime(stoi(temp))){
// cout<<temp<<endl;
count++;
i = j;
break;
}
}
}
cout<<count<<endl;
return 0;
}