Find the number of positive integers less than or equal to N that have an odd number of digits | Function to return the number of positive integers less than or equal to N that have odd number of digits ; Driver code
function odd_digits ( n ) { if ( n < 10 ) return n ; else if ( n / 10 < 10 ) return 9 ; else if ( n / 100 < 10 ) return 9 + n - 99 ; else if ( n / 1000 < 10 ) return 9 + 900 ; else if ( n / 10000 < 10 ) return 909 + n - 9999 ; else return 90909 ; } let n = 893 ; document . write ( odd_digits ( n ) ) ;