Find Maximum length of number
for ( let i = 0 ; i < 9 ; i ++ ) { frac [ i ] = Math . floor ( sum / arr [ i ] ) ; if ( frac [ i ] > maxi ) { pos = i ; maxi = frac [ i ] ; } } for ( let i = 0 ; i < maxi ; i ++ ) { ans . push ( String . fromCharCode ( ( pos + 1 ) + ' ' . charCodeAt ( 0 ) ) ) ; } sum -= maxi * arr [ pos ] ;