Skip to content

Instantly share code, notes, and snippets.

@gmuller
Created September 29, 2011 15:48
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 gmuller/1251050 to your computer and use it in GitHub Desktop.
Save gmuller/1251050 to your computer and use it in GitHub Desktop.
Simple recursive function for an algorithm question I had.
def getValueByLocation(x, y)
if x < 0 || y < 0
return nil
end
if x == y || y == 0
return 1
end
getValue(x - 1, y - 1) + getValue(x - 1, y)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment