Skip to content

Instantly share code, notes, and snippets.

@scottmascio2115
Created August 11, 2013 21:29
Show Gist options
  • Save scottmascio2115/6206925 to your computer and use it in GitHub Desktop.
Save scottmascio2115/6206925 to your computer and use it in GitHub Desktop.
recursive_methods.rb
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