JSFiddle - React, Tailwind, and code Playground

by Derek Leung

JavaScript

function removeNb(n){
	var sum = (1 + n) * n / 2;
    var candidates = [];
    
    for(var y = n; y >= 1; y--){
    	x = (-y + sum) / (y + 1);
        if(x % 1 == 0 && 1 <= x && x <= n)
        	candidates.push([x, y]);
    }
    
    return candidates;
}

console.log(removeNb(26));
console.log(removeNb(100));