```
var res;
var combine = function(n, k) {
res = [];
if(k !== 0)
combineRec([],n,k)
return res;
};
function combineRec(arr,n, k) {
lastElm = arr[arr.length-1];
if(k === 0)
res.push(arr);
else if(lastElm !== n) {
start = (lastElm === undefined ? 1 : lastElm + 1);
for(var i = start; i <= n ; i++)
combineRec(arr.concat(i),n,k-1);
}
}
```