Minimize the sum of digits of A and B such that A + B = N | Java implementation of the approach ; Function to return the minimum possible sum of digits of A and B such that A + B = n ; Find the sum of digits of n ; If num is a power of 10 ; Driver code
class GFG { static int minSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += ( n % 10 ) ; n /= 10 ; } if ( sum == 1 ) return 10 ; return sum ; } public static void main ( String [ ] args ) { int n = 1884 ; System . out . print ( minSum ( n ) ) ; } }