```function LastRemaining_Solution(n, m)
{
    // write code here
    if(n<1||m<1){return null}
    let arr=[]
    for(let i=0;i<n;i++){
        arr.push(i)
    }
    let index=0 //记录当前索引号
    while(arr.length>1){
        index=(index+m-1)%arr.length //之前下来的index相当于新一轮的第0索引号,数到m-1出局
        arr.splice(index,1) //出局
    }
    return arr[0]
}
module.exports = {
    LastRemaining_Solution : LastRemaining_Solution
};