function sequence(start=0, step=1) {
var counter = start-step;
return function(step){
return counter+step;
};
}
var generator = sequence(10, 3);
var generator2 = sequence(7, 1);
console.log(generator()); // 10
console.log(generator()); // 13
console.log(generator2()); // 7
console.log(generator()); // 16
console.log(generator2()); // 8
CmZ1bmN0aW9uIHNlcXVlbmNlKHN0YXJ0PTAsIHN0ZXA9MSkgewoKCXZhciBjb3VudGVyID0gc3RhcnQtc3RlcDsKCglyZXR1cm4gZnVuY3Rpb24oc3RlcCl7CgkJcmV0dXJuIGNvdW50ZXIrc3RlcDsKCX07Cn0KdmFyIGdlbmVyYXRvciA9IHNlcXVlbmNlKDEwLCAzKTsKdmFyIGdlbmVyYXRvcjIgPSBzZXF1ZW5jZSg3LCAxKTsKCmNvbnNvbGUubG9nKGdlbmVyYXRvcigpKTsgLy8gMTAKY29uc29sZS5sb2coZ2VuZXJhdG9yKCkpOyAvLyAxMwoKY29uc29sZS5sb2coZ2VuZXJhdG9yMigpKTsgLy8gNwoKY29uc29sZS5sb2coZ2VuZXJhdG9yKCkpOyAvLyAxNgoKY29uc29sZS5sb2coZ2VuZXJhdG9yMigpKTsgLy8gOA==