Minimum count of digits required to obtain given Sum | C ++ program to implement the above approach ; Function to return 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void mindigits ( int n ) { if ( n % 9 == 0 ) { cout << n / 9 << endl ; } else { cout << ( n / 9 ) + 1 << endl ; } } int main ( ) { int n1 = 24 ; int n2 = 14 ; mindigits ( n1 ) ; mindigits ( n2 ) ; }