Skip to content

Instantly share code, notes, and snippets.

@tomgullo
Created January 24, 2013 20:00
Show Gist options
  • Save tomgullo/4627084 to your computer and use it in GitHub Desktop.
Save tomgullo/4627084 to your computer and use it in GitHub Desktop.
get coordinate for pascal triangle
/*
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
*/
def getNum(int x, int y) {
if (y == 0) {
return 1
} else if (x == y) {
return 1
} else {
return getNum(x-1, y-1) + getNum(x-1, y)
}
}
getNum(4 ,1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment