Check if all prefixes of a number is divisible by remaining count of digits | Function to check if all prefixes of a number is divisible by remaining count of digits or not ; Traverse and check divisibility for each updated number ; Update the original number ; Given Input ; Function Call
function prefixDivisble ( n ) { let i = 1 ; while ( n > 0 ) { if ( n % i != 0 ) return false ; n = parseInt ( n / 10 ) ; i ++ ; } return true ; } let n = 52248 ; if ( prefixDivisble ( n ) == true ) document . write ( " " ) ; else document . write ( " " ) ;