# A prime number wall pool table

Assume we have an idealized even- and $n$-sided pool table with no holes, friction and perfectly reflecting walls, and that a ball is set in motion (inside the table) parallel to one of the sides and towards the middle point of the wall of the first contact.

For a 3-sided table the ball would describe an eternal path in another inscribed triangle, for a 4-sided table there are two states of such eternal paths.

I now wonder, for $n$ number of walls is there only one state or path if $n$ is a prime number, and would there be perhaps $m$ number of states if $n$ is a factor of $m$ primes?

• Are you assuming the table edges are all the same length? i.e. the table is a regular polygon? – Ben Millwood Jul 24 '13 at 12:03
• it would be helpful if you attach some images as example. – al-Hwarizmi Jul 24 '13 at 12:35
• Yes, I intended the edges to be the same length by using the term "even-sided". – Mikael Jensen Jul 24 '13 at 19:47

By symmetry with respct to the mid-perpendicular of the side the motion is parallel to, the ball moves by an even number $2k$ of sides (which may be more than $\frac n2$, as in the case $n=3$) and the (polygonal or star) shape of the path is uniquely determined by the number $2k$, except that $n-2k$ and $2k$ generate the same. So if $n=2m$ is even, we have to check $k$ ranging from $1$ to $\lfloor \frac m2\rfloor =\lfloor \frac n4\rfloor$ inclusive, if $n$ is odd $k$ ranging from $1$ to $\frac{n-1}2$ inclusive. For each such $k$, one closed cycle involves every $d$th edge where $d=\gcd(n,2k)$, so we get $d$ distinct rotational copies of this path and the total number of closed cycles is $$\tag1 \sum_{k=1}^{\lfloor\frac n4\rfloor\text{ or }\frac{n-1}2}\gcd(n,2k).$$ It seems that this sequence $$0, 0, 1, 2, 2, 2, 3, 6, 6, 4, 5, 12, 6, 6, 15, 16, 8, 12, 9, 22, 22, 10, 11, 34, 20, 12, 27, 32, 14, 30$$ is not in OEIS (yet). By the way, if $n$ is an odd prime, then $(1)$ equals $\frac{n-1}{2}$.

Let $$R$$ be a regular $$n$$-gon, and number the midpoints of its sides $$0$$ through $$n-1$$.

Note that if a line passing through the midpoint of a side is parallel to another side, then it passes through the midpoint of another side. For odd $$n$$ the converse holds; a line passing through the midpoints of two distinct sides is parallel to another side. For even $$n$$ this only holds if the sides differ by an even number (assuming we have numbered the sides in a sensible way).

Hence we may describe the initial motion as starting from a point $$p\in\{0,\ldots,n-1\}$$, towards another point $$q\in\{0,\ldots,n-1\}$$, where $$p\neq q$$. Denote the path starting from point $$p$$ moving towards $$q$$ by $$P(p,q)$$.

Consider the path $$P(0,m)$$. After meeting point $$m$$, the ball is reflected and moves towards point $$2m$$. By symmetry, the $$k$$-th point to be met is the point $$k\cdot m$$, so the points on the path $$P(0,m)$$ are the integer multiples of $$m$$, modulo $$n$$ of course.

Counting orientation, this yields precisely $$n-1$$ distinct paths meeting $$0$$ if $$n$$ is odd, and precisely $$\tfrac{n}{2}-1$$ distinct paths meething $$0$$ if $$n$$ is even. Of course not every path meets the point $$0$$ necessarily. The length of $$P(0,m)$$, i.e. the number of distinct points it meets, is $$\operatorname{lcm}(m,n)/n$$, or equivalently $$m/\gcd(m,n)$$, whichever you prefer, so there are precisely $$\gcd(m,n)$$ distinct 'rotations' of this path. The total number of distinct paths, counting orientation, is therefore

$$T(n)=\left\{\begin{array}{cc} \sum_{m=1}^{n-1}\gcd(m,n)&\text{ for } n \text{ odd,}\\ \sum_{m=1}^{\tfrac{n}{2}-1}\gcd(2m,n)&\text{ for } n \text{ even.}\end{array}\right.$$

This is not as bad as it looks; it turns out these sums are multiplicative. For details, see this question. The accepted answer there shows that if $$n=\prod_{p\mid n} p^{n_p}$$ then $$\sum_{m=1}^n\gcd(m,n)=n\prod_{p\mid n}\big(1+n_p(1-\tfrac1p)\big).$$

So indeed this shows that the number of paths on an $$n$$-sided table is closely related to the factorization of $$n$$.

Also, if we don't count orientation, we find the total numbers to be

$$t(n)=\left\{\begin{array}{cc} \frac{1}{2}(T(n)+n)&\text{ if } 4\mid n\\ \frac{1}{2}T(n)&\text{ otherwise}\end{array}\right..$$

• Thank you for the answers. I must say I thought the solution would be much easier than it seems. – Mikael Jensen Jul 24 '13 at 19:50