text: Minimize coins required to obtain all possible values up to N | Function to find minimum count of { 1 , 2 , 5 } valued coins required to make a change of all values in the range [ 1 , N ] ; Number of 5 valueds coins required ; Number of 1 valued coins required ; Number of 2 valued coins required ; Driver Code
code: function find ( N ) { var T , F , O ; F = parseInt ( ( N - 4 ) / 5 ) ; if ( ( ( N - 5 * F ) % 2 ) == 0 ) { O = 2 ; } else { O = 1 ; } T = Math . floor ( ( N - 5 * F - O ) / 2 ) ; document . write ( " " + F + " " ) ; document . write ( " " + T + " " ) ; document . write ( " " + O + " " ) ; } var N = 8 ; find ( N ) ;