Smallest and Largest sum of two n | Function to return the smallest sum of 2 n - digit numbers ; Function to return the largest sum of 2 n - digit numbers ; Driver code
function smallestSum ( n ) { if ( n == 1 ) return 0 ; return ( 2 * Math . pow ( 10 , n - 1 ) ) ; } function largestSum ( n ) { return ( 2 * ( Math . pow ( 10 , n ) - 1 ) ) ; } var n = 4 ; document . write ( " " + largestSum ( n ) + " " ) ; document . write ( " " + smallestSum ( n ) ) ;