Minimum jumps to traverse all integers in range [ 1 , N ] such that integer i can jump i steps | Utility function to find minimum steps ; Input integer ; Function call
function minSteps ( N ) { var res = parseInt ( ( Math . sqrt ( 1 + 8 * N ) - 1 ) / 2 ) ; return res ; } var N = 6 ; document . write ( minSteps ( N ) ) ;