loading...

re: Daily Challenge #132 - Is my friend cheating? VIEW POST

FULL DISCUSSION
 

function removeNb(n) {
  const arr = [...Array(n + 1).keys()]
  const acc = n*(n+1)/2;
  return Array.prototype.concat.apply([], arr.map(i => arr.map(x => [i,x]))) .filter(([a,b])=>  a * b == acc - a - b )
}

 

Bonus points for using the sum formula for arithmetic sequences :-)

Code of Conduct Report abuse