How to find the $n$th term of a repeating pattern What is the nth term of following sequence 
 $1,2,3,4,5,6,1,2,3,4,5,6,\ldots$
$(n, n+1, n+2, n+3,\ldots,$ $,n+p, n, n+1, n+2, n+3,$ $n+4, n+5,$ $\ldots,$ $n+p,$ $n,$ $n+1,$ $\ldots)$
Actually, I am trying to solve the following puzzle
 $6$ girls pick a captain by forming a circle then eliminating every $m$th girl. The 2nd girl in the counting order can choose $m$. If she wants to be captain what's the smallest $m$ she should pick?

The $n$-th term of sequence $1,2,3,4,5,6,1,2,3,4,5,6,\ldots$ is given by $a_n=1+(n-1 \bmod 6)$.
