Smallest even digits number not less than N | function to check if all digits are even of a given number ; iterate for all digits ; if digit is odd ; all digits are even ; function to return the smallest number with all digits even ; iterate till we find a number with all digits even ; Driver Code
function check_digits ( n ) { while ( n != 0 ) { 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 ) != 0 ) return i ; } var N = 2397 ; document . write ( smallest_number ( N ) ) ;