Description

现在有n个人围成一个圈,每个人的编号分别为1~n,从1号开始报数,每当一个人报的数是7的倍数的时候,就退出圈圈,其他的人接着继续报数,一直到最后一个人出圈。比方说现在有七个人围在一起,编号分别为1-7,那么7个人退出队列的顺序分别是:7、1、3、6、2、4、5.

Input 输入正整数n(n>0)

Output 输出出圈顺序

Untitled

coding:

n = input()

top = 0

loop_list = [i + 1 for i in range(int(n))]

while len(loop_list) > 0:
    top = (top + 7) % len(loop_list)
    if top == 0:
        top = len(loop_list)
    top -= 1
    print(loop_list[top])
    del (loop_list[top])