Check if frequency of each digit is less than the digit | Function to validate number ( Check if frequency of adigit 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
< ? php function validate ( $ n ) { for ( $ i = 0 ; $ i < 10 ; $ i ++ ) { $ temp = $ n ; $ count = 0 ; while ( $ temp ) { if ( $ temp % 10 == $ i ) $ count ++ ; if ( $ count > $ i ) return -1 ; $ temp /= 10 ; } } return 1 ; } $ n = 1552793 ; $ geek = validate ( $ n ) ? " True " : " False " ; echo ( $ geek ) ; ? >