Skip to content

Instantly share code, notes, and snippets.

@eibrahim
Created February 2, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eibrahim/0768dcb56ffa854f5abd to your computer and use it in GitHub Desktop.
Save eibrahim/0768dcb56ffa854f5abd to your computer and use it in GitHub Desktop.
Sum of integers from 1 to n
def sum 1 do 1 end
def sum n do n + sum (n - 1) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment