Explicitly handle first digit and call recursive function findNDigitNumsUtil for remaining indexes . Note that the first digit is considered to be present in even position
for ( int i = 1 ; i <= 9 ; i ++ ) { ou [ index ] = ( char ) ( i + '0' ) ; findNDigitNumsUtil ( n , ou , index + 1 , evenSum + i , oddSum ) ; } }