Minimum count of digits required to obtain given Sum | Java program to implement the above approach required to make the 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
import java . util . * ; class Main { static void mindigits ( int n ) { if ( n % 9 == 0 ) { System . out . println ( n / 9 ) ; } else { System . out . println ( ( n / 9 ) + 1 ) ; } } public static void main ( String [ ] args ) { int n1 = 24 ; int n2 = 18 ; mindigits ( n1 ) ; mindigits ( n2 ) ; } }