Add 1 , 2 , 3 , ... with corresponding values
for ( i = 0 ; i < k ; i ++ ) array [ i ] += i + 1 ; if ( k - 1 != remaining k == 1 ) { for ( var u = 0 ; u < array . length ; u ++ ) document . write ( array [ u ] + " " ) ; }