Created
August 11, 2013 21:29
-
-
Save scottmascio2115/6206925 to your computer and use it in GitHub Desktop.
recursive_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choose_team(n, k) | |
return n if k == 1 | |
return 0 if n == 0 | |
choose_team(n-1, k-1) + choose_team(n-1,k) | |
end | |
puts choose_team(6,3) == 20 | |
puts choose_team(6,2) == 15 | |
puts choose_team(24,4) == 10626 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment