SOURCE

function countOff(n,m) {
    let players = [];
    for (let i = 1;i <= n;i++) {
        players.push(i);
    }
    let flag = 0;
    while(players.length > 1) {
        let len = players.length;
        let outNum = 0;
        for (let i = 0;i < len;i++) {
            flag++;
            if (flag === m) {
                flag = 0;
                players.splice(i-outNum, 1);
                outNum++;
            }
        }
    }

    console.log("剩下的是:" + players[0]);
}

countOff(5,3);
// countOff(100,10);
console 命令行工具 X clear

                    
>
console