题目
有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 12 19:36:37 2019
@author: Franz
"""
n = int(input('number: '))
num = [i for i in range(1,n+1)]
i = 0 # 计数符号
k = 0 # 索引符号
while True:
z = 0
if num[k] != 0:
i = i + 1
if i % 3 == 0:
num[k] = 0
i = 0
k = k + 1
if k == len(num):
k = 0
for j in range(len(num)):
if num[j] != 0: z = z + 1
if z == 1:
break