For a set S with elements n and an integer k . I need to find the sum of the products of all n to choose pairs k . That is, if S = {1,2,3,4} and k = 2 , then I'm looking for P = 1*2 + 1*3 + 1*4 + 2*3 + 2*4 +3*4 . Note that product pairs are a collection of elements k different elements from a collection of elements n . I can formulate a simple version of dynamic programming:
P(n,k) = a_{n}P(n-1,k-1) + P(n-1,k)
That is, take n-1 elements and select k-1 and add a_{n} , and also leave a_{n} . Is there any good theory to find a closed-form solution for the above problem? I'm a little lacking in advanced math, although programming worries me. I was able to withdraw the aforementioned DP, but could not go to the closed form, which, I hope, is!
source share