#include<iostream>
#include<vector>
#include<queue>

using namespace std;
int main(){
    int n,k;
    cin >>n>>k;
    queue <int> q;
    for(int i=1;i<=n;i++)
    {
        q.push(i);
    }
    while(!q.empty()){
        for(int i=0;i<k-1;i++)
        {
        q.push(q.front());
        q.pop();
    }
    cout <<q.front();
    q.pop();
    if(!q.empty()){
        cout<<", ";
    }
}
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: