Skip to content

Instantly share code, notes, and snippets.

@sionleroux
Last active February 14, 2016 14:59
Show Gist options
  • Save sionleroux/d0578c2b65fe9f2b26f6 to your computer and use it in GitHub Desktop.
Save sionleroux/d0578c2b65fe9f2b26f6 to your computer and use it in GitHub Desktop.
Short, mathematical solution to Sum All Numbers in Range problem
function sumAll(x) {return (x[1] + x[0]) * (Math.abs(x[1] - x[0]) + 1) / 2;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment