If i = 0 , any digit from [ 1 - 9 ] can be placed and also if N = 1 , then 0 can also be placed
if ( i == 0 ) { for ( int digit = ( n == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { val += solve ( i + 1 , n , digit , sign ) ; } }