Scanner sc = new Scanner(System.in);
int n =sc.nextInt();
String s = sc.next();
boolean[] a = new boolean[1_000_005];
Arrays.fill(a, true);
a[0] = false;
a[1] = false;
// if u get a true i.e. its prime therefore mark all its multiple false this gives a array with prime number index true
for (int i = 2; i * i < 1_000_005; i++) {//applying sieve or eratosthenes
if (a[i]) {
for (int j = i * i; j < 1_000_005; j += i) {//mark multiple false
a[j] = false;
}
}
}
int c = 0;
for(int i=0;i<n;i++) {
for(int j=i+1;j<=n;j++) {
String ss = s.substring(i,j);
int x = Integer.parseInt(ss);
if(a[x]) {
c++;
i=j;
}
}
}
System.out.println©;
RUN ERROR IN MANY TEST CASES
there can be cb number as well that are non prime for example
37*37 (it is not prime but it is cb number)
so correct it and then try to submit again