Skip to content

Instantly share code, notes, and snippets.

@ctide
Forked from anonymous/gist:5267731
Last active December 15, 2015 13:29
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 ctide/5267734 to your computer and use it in GitHub Desktop.
Save ctide/5267734 to your computer and use it in GitHub Desktop.
def pascal(c: Int, r: Int): Int = {
if (r < 1 || c < 1 || (c == r)) 1 // handles top of the triangle, and the sides
else pascal(c - 1, r - 1) + pascal(c, r - 1)
}
def pascal(c: Int, r: Int): Int = {
if (c == 0 || r == 0 || r == c) 1 else pascal(c - 1, r - 1) + pascal(c, r - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment