Minimum count of digits required to obtain given Sum | Function to print the minimum count of digits ; IF N is divisible by 9 ; Count of 9 's is the answer ; If remainder is non - zero ; Driver Code
function mindigits ( n ) { if ( n % 9 == 0 ) { document . write ( Math . floor ( n / 9 ) + " " ) ; } else { document . write ( Math . floor ( n / 9 ) + 1 + " " ) ; } } let n1 = 24 ; let n2 = 18 ; mindigits ( n1 ) ; mindigits ( n2 ) ;