Given
m: number of posters to design
n: total number of available colors
solve for
x: number of colors for each poster so that each poster has a unique combination of colors
subject to the equation
(n choose x) = m
I have coded the above problem in python and the source code is given below
factorial = []
def generateList(n):
factorial.append(1)
factorial.append(1)
for i in range(2,n+1):
factorial.append(i * factorial[i-1])
def calculateFac(n,i):
return int((factorial[n]) / (factorial[i] * factorial[n-i]))
def ColorChoice(m,n):
for i in range(1,int(n/2)+1):
if m == calculateFac(n,i):
return i
return -1
def checkChoose(m,n):
generateList(n)
return ColorChoice(m,n)
print (checkChoose(35,7))
The above solution will only work for small integers but I need a solution to work for larger numbers, e.g. when n = 47129212243960.
Is there any efficient way to solve this?