const fs = require('fs');
const input = fs.readFileSync(0, 'utf-8').trim();
const [all, num] = input.split(' ').map(Number);
const result = [];
let idx = 0;
const newAll = Array.from({length: all}, (v,i) => i + 1);
while (newAll.length > 0){
idx = (idx + num - 1) % newAll.length;
result.push(newAll.splice(idx, 1)[0]);
}
console.log('<' + result.join(', ') + '>');
splice() 메서드는 배열의 기존 요소를 삭제 또는 교체하거나 새 요소를 추가하여 배열의 내용을 변경합니다.
splice하면 Array가 변경되고 제거한 요소의 배열을 반환한다.