有大佬帮忙解读一下这段代码的功能实现吗

#include
#include
struct node {
int no;
struct node * next;
};

main( )
{   int i, k;  struct node *head, *p, *q;
    head = (struct node *)malloc(sizeof(struct node));
    head->no   = -1;
    head->next = head;
    for ( i=30; i>0; i-- )                     
    {   p = (struct node *)malloc(sizeof(struct node));
        p->next = head->next;  p->no   = i;  head->next = p;
    }
    printf("\nThe original circle is :");
    while ( p->next != head )            
        p = p->next;
    p->next = head->next;                     
    for ( i=0; i<15; i++ )
    {   for ( k=1 ; k<9 ; k++ )
         p = p->next;
        q = p->next;                
        p->next = q->next;         
        printf("%3d", q->no);   
        free(q);                             
    }
}

看上去好像是约瑟夫环的问题
https://www.cnblogs.com/cmmdc/p/7216726.html