Check if frequency of each digit is less than the digit | Function to validate number ( Check iffrequency of a digit is less than thedigit itself or not ) ; If current digit of temp is same as i ; if frequency is greater than digit value , return false ; Driver Code
function validate ( n ) { for ( let i = 0 ; i < 10 ; i ++ ) { let temp = n ; let count = 0 ; while ( temp > 0 ) { if ( temp % 10 == i ) count ++ ; if ( count > i ) return false ; temp /= 10 ; } } return true ; } let n = 1552793 ; if ( validate ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;