再对比一下相应的javascript代码

来源: 2012-06-20 22:59:22 [博客] [旧帖] [给我悄悄话] 本文已被阅读:

function countingoff(count, steps) {

    var people = []

    while (count) { people.unshift(count--)}

    var idx = 0

    while (people.length) {

        idx = (idx + steps - 1)%people.length

        console.log("removed: #", people.splice(idx, 1)[0], ", left: ", people)

    }

}

// example

countingoff(25, 7)