Represent a number as the sum of positive numbers ending with 9 | Function to find the minimum count of numbers ending with 9 to form N ; Extract last digit of N ; Calculate the last digit ; If the last digit satisfies the condition ; Driver Code
function minCountOfNumbers ( N ) { let k = N % 10 ; let z = N - ( 9 * ( 9 - k ) ) ; if ( z >= 9 && z % 10 == 9 ) { return 10 - k ; } else { return - 1 ; } } let N = 156 ; document . write ( minCountOfNumbers ( N ) ) ;