If there is no highest prime less than current digit .
else { int j = size - 1 ; while ( j > 0 && prevprime [ N [ j ] - '0' ] == 0 ) { ans [ j ] = N [ j ] = '7' ; N [ j - 1 ] = prevprime [ N [ j - 1 ] - '0' ] + '0' ; ans [ j - 1 ] = N [ j - 1 ] ; small = 1 ; j -- ; } } }