Check for a subsequence of size 1
for ( int j = 0 ; j < S . Length ; j ++ ) { if ( S [ j ] != '2' && S [ j ] != '3' && S [ j ] != '5' && S [ j ] != '7' ) { Console . WriteLine ( 1 ) ; flag = true ; break ; } }