Link to original title
This question is actually a question about the Joseph ring. If it is actually simulated, it is indeed a bit strenuous. However, there is a very simple algorithm for this problem. For specific principles, please refer to the formula solution to the Joseph ring problem
in this article
The body code is as follows
n,pos = eval(input()),0
for cnt in range(2,n+1):
pos = (pos+3)%cnt
print(pos+1)
As long as you understand the principle of the formula, the code is actually quite concise.