(*https://jmorken.github.io/20210505%20tree%20of%20composites/tree%\
20of%20composites%20page3%20-%20additional%20proportions.htm*)



(* fastest code, see: https://mathematica.stackexchange.com/questions/301564/solving-a-system-of-equations-and-inequalities-with-5-variables/301569#301569 *)
(*code for integer solutions*)
FindInstance[(a/210)*0 + (b/210)*1 + (c/210)*2 + (d/210)*3 + (e/
        210)*4 == 1/2 + 1/3 + 1/5 + 1/7 &&
   0 <= {a, b, c, d, e} <= 210 && a + b + c + d + e == 210 &&
   d <= e, {a, b, c, d, e}, Integers, 50000];
Dimensions[%]


(*code for real number solutions*)
Reduce[(a/210)*0 + (b/210)*1 + (c/210)*2 + (d/210)*3 + (e/210)*4 ==
   1/2 + 1/3 + 1/5 + 1/7 && 0 <= {a, b, c, d, e} <= 210 &&
  a + b + c + d + e == 210 && d <= e, {a, b, c, d, e}, Reals]





(*this below code is slow*)
Print["test to see how rare the a,b,c,d,e values are (there are \
multiple solutions to the equation)"]

247/210 == (48/210)*0 + (92/210)*1 + (56/210)*2 + (13/210)*3 + (1/
     210)*4 == 1/2 + 1/3 + 1/5 + 1/7

p1 = 2;
p2 = 3;
p3 = 5;
p4 = 7;
x = p1*p2*p3*p4;
y = 1/p1 + 1/p2 + 1/p3 + 1/p4;
a = 48;
b = 92;
c = 56;
d = 13;
e = 1;

247/x == (a/x)*0 + (b/x)*1 + (c/x)*2 + (d/x)*3 + (e/x)*4 == y

trueListabcde = {};
trueSumXCount = 0;
trueCount = 0;
falseCount = 0;
For[a = 30, a < 60, a++,
 For[b = 70, b < 100, b++,
  For[c = 40, c < 70, c++,
   For[d = 0, d < 30, d++,
    For[e = 0, e < 30, e++,
     If[x == a + b + c + d + e,
      trueSumXCount = trueSumXCount + 1;
      If[247/x == (a/x)*0 + (b/x)*1 + (c/x)*2 + (d/x)*3 + (e/x)*4 == y,
       (*Print[{a,b,c,d,e}];*)
       AppendTo[trueListabcde, {a, b, c, d, e}];
       trueCount = trueCount + 1
       ],
      falseCount = falseCount + 1
      ]
     ]
    ]
   ]
  ]
 ]
trueSumXCount
trueCount
falseCount
N[trueCount/falseCount]
N[falseCount/trueCount]
Length[trueListabcde]
Take[trueListabcde, 10]


(*some other abcde solutions:
{{39, 99, 68, 4, 0}, {39, 99, 69, 2, 1}, {40, 97, 69, 4, 0}, {40, 98,
  67, 5, 0}, {40, 98, 68, 3, 1}, {40, 98, 69, 1, 2}, {40, 99, 65, 6,
  0}, {40, 99, 66, 4, 1}, {40, 99, 67, 2, 2}, {40, 99, 68, 0, 3}} *)