Skip to content

Instantly share code, notes, and snippets.

@alex-hladun
Created May 29, 2020 17:43
Show Gist options
  • Save alex-hladun/a8e19ae4797d1e248352da057a6f09fe to your computer and use it in GitHub Desktop.
Save alex-hladun/a8e19ae4797d1e248352da057a6f09fe to your computer and use it in GitHub Desktop.
Sum from one number to another recursively.
const sum = function(fromN, toN) {
if (fromN === toN) {
return toN;
} else {
return fromN + sum(fromN + 1, toN);
}
};
module.exports = sum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment