Eeny meeny miny mo equation In the game eeny meeny miny mo (a type of counting-out game) is there a pure maths equation that can determine which person gets selected? Assumptions:


*

*N people are arranged in a circle numbered 1 to N

*The rhyme has 16 steps (S=16)

*No programming logic (i.e. no if-then-else type structures)


The equation needs to satisfy the following data where N is the input (number of people) and P is the output (selected person):

N  P
1  1
2  2
3  1
4  4
5  1
6  4
7  2
8  8
9  7
10 6
11 5
12 4 
13 3
14 2
15 1
16 16

As this is a 'circular problem' the modulo function seems required. So using this I get:

N  16%N
1   0    
2   0    
3   1    
4   0    
5   1    
6   4    
7   2    
8   0    
9   7    
10  6    
11  5    
12  4    
13  3    
14  2    
15  1    
16  0    

Applying a bit of logic after the modulo function (replace zero with N)  a formula can be obtained. In Python, for example, this can be expressed simply as   

P = (16 % N) or N

or more generally

P = (S % N ) or N

However, this uses programming logic. Is this possible without using logic? Or is there something fundamental that makes this impossible?
 A: One correct computation using modulo arithmetic is $P=(S-1)\%N+1$.
This works assuming the modulo $N$ operation (as in most computer languages) yields values in the range $0, \dots, N-1$.  If we label the $N$ people as $0,\dots, N-1$ then picking the $S$-th person corresponds to finding $P=(S-1)\%N$. The '$+1$' converts the result back the scheme where people are labelled $1,\dots, N$.  There are no special cases for $S\le N$ vs. $S > N$.
A: There are two cases:


*

*Case $S>N$: Then

P = (S % (N+1)) + 1

gives the correct answer, which is always less then $S$.

*Case $S\leq N$: Then the answer is $S$.
Combining these two cases into a formula, you get

P = min((S % (N+1)) + 1, S)

So in relation to your expectations this can count as an answer. But please note that the complexity of this function is hidden by the minimum operator and by the modulo operator.
In a more general context, your question is unanswerable, because the question lacks additional information on which mathematical operations you want to allow (this was already mentioned in the comments to your question).
