Check for a subsequence of size 2
if ( ! flag ) { for ( int j = 0 ; j < S . Length - 1 ; j ++ ) { for ( int j1 = j + 1 ; j1 < S . Length ; j1 ++ ) { dummy = S [ j ] . ToString ( ) + S [ j1 ] . ToString ( ) ; if ( dummy != "23" && dummy != "37" && dummy != "53" && dummy != "73" ) { Console . WriteLine ( 2 ) ; } if ( flag == true ) break ; else flag = true ; } if ( flag == true ) break ; } }