If it were just the right had side of (A) we needed to get all the possibilities for, we could use a standard formula for distributing 44 among four variables: C(44+(4-1),(4-1))=C(47,3)=16215.
But now, each of those 16,215 possibilities for the RHS has multiple ways of allocating its prime factors (a different set in each case) to the five variables on the LHS.
In each case, the X factors of 7 and the Y factors of 11 and the Z factors of 13 and the W factors of 79 need to be apportioned separately and the results multiplied:
C(X+4,4) * C(Y+4,4) * C(Z+4,4) * C(W+4,4)
the 4 in each case is 1 less than the number of partitions: P, Q, R, S, T.
These 16,215 products then need to be added together for the final result.
DECLARE FUNCTION combi# (a#, b#)
DEFDBL A-Z
FOR x = 0 TO 44
FOR y = 0 TO 44 - x
FOR z = 0 TO 44 - x - y
w = 44 - x - y - z
ct = ct + combi(x + 4, 4) * combi(y + 4, 4) * combi(z + 4, 4) * combi(w + 4, 4)
NEXT
NEXT
NEXT
PRINT ct
FUNCTION combi (a, b)
c = 1
FOR i = a TO a - b + 1 STEP -1
c = c * i
NEXT
FOR i = 1 TO b
c = c / i
NEXT
combi = c
END FUNCTION
or, alternatively, to assure best precision:
10 FOR x = 0 TO 44
20 FOR y = 0 TO 44 - x
30 FOR z = 0 TO 44 - x - y
40 w = 44 - x - y - z
50 ct = ct + combi(x + 4, 4) * combi(y + 4, 4) * combi(z + 4, 4) * combi(w + 4, 4)
60 NEXT
70 NEXT
80 NEXT
90 PRINT ct
Either way, the answer is 6,131,164,307,078,475 or over 6 quadrillion, in American speak. or over 6 thousand billion in British speak.
|
Posted by Charlie
on 2013-09-26 13:01:45 |