Hint For Project Euler Problem 106 - Special Subset Sums - Meta Testing

Here is my hint for Project Euler Problem 106 - Special Subset Sums - Meta Testing.

Summary
function subsetSumsMetaTesting() {
  function factorial(num) {
    return num>1 ? factorial(num-1) * num : 1;
  }
  let n = 12;
  let factorials = Array(n+1).fill(1).map((e,i) => factorial(i));
  let result = 0;
  for (let k=2;k<=Math.floor(n/2);k++) {
    result += (0.5*(k-1)*factorials[n]/(factorials[k]**2*factorials[n-2*k]*(k+1)));
  }
  return result;
}

subsetSumsMetaTesting();

Hi, thanks for the solution suggestion. Can you add some comments explaining how the formula works?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.