Skip to content

Instantly share code, notes, and snippets.

@arose13
Last active November 27, 2015 19:38
Show Gist options
  • Save arose13/2d23cedcebe63f9ae5a8 to your computer and use it in GitHub Desktop.
Save arose13/2d23cedcebe63f9ae5a8 to your computer and use it in GitHub Desktop.
# Number of Combinations for pool size (n) and choosing (k) number per set.
# Author arose13
import math
def number_of_combinations(n, k):
numer = n
denom = k
for i in range(1, k):
numer = numer * (n - i)
denom = denom * (i)
combos = numer / denom
print("-----------------------------")
print("Number of combinations = " + str(combos))
print("A number with " + str(math.floor(math.log10(combos))) + " zeros")
print("-----------------------------")
# Expected answer = 2,598,960
number_of_combinations(52, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment