Code in Python(3.x recommended)

Output:

#----------------Code-----------------
#Assumption: Any box contains at least one ball
# This is partition problem which uses this recursion to
solve:
# part(n,k) = part(n-1,k-1) + part(n-k,k), where n=an integer (or
balls)
# k=partitions (or boxes)
def generate(n, k):
if(n<k): # when number of balls < number of boxes, then
return 0
return(0)
if(k-1==0 or k==0): # condition for recursion to end
return(1)
return(generate(n-1, k-1)+generate(n-k, k))
ball=int(input()) # number of ball
box=4
#number of ways to distribute k identical balls into four
indistinguishable boxes
print(generate(ball, box))
Define a generating function model for the number of ways to distribute k identical balls into...