Generate minimum sum sequence of integers with even elements greater | Function to print the required sequence ; arr [ ] will hold the sequence sum variable will store the sum of the sequence ; If sum of the sequence is odd ; Print the sequence ; Driver Code
function make_sequence ( N ) { var arr = Array ( N + 1 ) , sum = 0 ; for ( var i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) arr [ i ] = 1 ; else arr [ i ] = 2 ; sum += arr [ i ] ; } if ( sum % 2 == 1 ) arr [ 2 ] = 3 ; for ( var i = 1 ; i <= N ; i ++ ) document . write ( arr [ i ] + " " ) ; } var N = 9 ; make_sequence ( N ) ;