Smallest odd digits number not less than N | function to check if all digits are odd of a given number ; iterate for all digits ; if digit is even ; all digits are odd ; function to return the smallest number with all digits odd ; iterate till we find a number with all digits odd ; Driver Code
function check_digits ( n ) { while ( n > 1 ) { if ( ( n % 10 ) % 2 == 0 ) return 0 ; n = parseInt ( n / 10 ) ; } return 1 ; } function smallest_number ( n ) { for ( i = n ; ; i ++ ) if ( check_digits ( i ) ) return i ; } let N = 2397 ; document . write ( smallest_number ( N ) ) ;