Last active
November 27, 2015 19:38
-
-
Save arose13/2d23cedcebe63f9ae5a8 to your computer and use it in GitHub Desktop.
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
# 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