Created
April 25, 2017 20:45
-
-
Save benevidesh/bd1f767cddbe54f1f65b5618c3d84395 to your computer and use it in GitHub Desktop.
calcular coeficiente binomial
This file contains hidden or 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 factorial(x): | |
fact = count = 1 | |
while count <= x: | |
fact = fact * count | |
count += 1 | |
return fact | |
def coefBinom(n, k): | |
aux = factorial(n) // (factorial(k) * factorial(n - k)) | |
return aux | |
n = int(input('Digite o valor de n: ')) | |
k = int(input('Digite o valor de k: ')) | |
print(coefBinom(n, k)) | |
This file contains hidden or 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 factorial(x): | |
fact = count = 1 | |
while count <= x: | |
fact = fact * count | |
count += 1 | |
return fact | |
def coefBinom(n, k): | |
aux = factorial(n) // (factorial(k) * factorial(n - k)) | |
return aux | |
print(coefBinom(10, 2)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment