Here we will write code that uses Python to calculate how many combinations there are duplicates.
python
from math import factorial
print("Enter two positive integers.")
a, b= map(int, input().split())
h = (factorial(a+b-1))/(factorial(b)*factorial(a-1))
print(str(a)+"From individual things"+str(b)+"How to choose one by allowing duplication"+str(h)+"It's a street.")
You can see all the functions included in math by writing as follows.
python
import math
help(math)
python
print("Enter two positive integers.")
a, b= map(int, input().split())
n = a + b -1
m = n
l = a-1
while n > b+1:
m = m * (n-1)
n = n - 1
while l > 0:
m = m / l
l = l -1
print(str(a)+"From individual things"+str(b)+"How to choose one by allowing duplication"+str(m)+"It's a street.")
Recommended Posts