9

My question is based on an observation made by Vepir in their question "Grasshopper jumping on circles".

Vepir's observation was essentially that the sequence of triangle numbers $T\colon \mathbb{Z} \rightarrow \mathbb{Z}$ $$ T(n) = \frac{n(n+1)}{2} $$ forms a permutation when the inputs are restricted to $\{0,1,\dots,2^k-1\}$ and the outputs are considered $(\text{mod } 2^k)$. Moreover, this only works modulo powers of two.

Example

For example, when $k=3$, the sequence is $$ \begin{alignat*}{8} n: &&\ 0,\ & 1,\ & 2,\ & 3,\ & 4,\ & 5,\ & 6,\ & 7\\ T(n): &&\ 0,\ & 1,\ & 3,\ & 6,\ & 10,\ & 15,\ & 21,\ & 28\\ T(n) \pmod {8}: &&\ 0,\ & 1,\ & 3,\ & 6,\ & 2,\ & 7,\ & 5,\ & 4 \end{alignat*} $$

Question

I showed this to a colleague, and he proved it was a bijection for all $2^m$, however, his proof involved a good deal of case analysis.

Is there a quick and easy way to see that the triangle numbers restrict to a permutation if and only if $k$ is a power of two?

Also, are there examples of polynomials with rational coefficients $f \in \mathbb Q[x]$ that restrict to a permutation if and only if $k$ is a power of three? A power of four? A prime number? A Fibonacci number?

Peter Kagey
  • 5,052
  • 5
    Fun fact: This was Problem 4 on the 1991 Asian Pacific Math Olympiad, and reappeared as Problem 5 of the Mexican National Contest. – ViHdzP Dec 29 '19 at 23:05
  • 1
    @URL: Interesting. But the first of those isn't actually the same problem; the teacher keeps going even if it take more than $n$ candies. The second one is indeed the same problem, since Nacho only places $n$ flags. – joriki Dec 29 '19 at 23:37
  • 1
    See also https://math.stackexchange.com/questions/1942790 and https://math.stackexchange.com/a/1928690. (The proof by Donald Knuth is on p. $947$ of this PDF file; it's essentially the proof in my answer, without the detour through adding $\frac18$.) – joriki Dec 30 '19 at 00:46
  • This question prompted me to ask this question. – joriki Dec 30 '19 at 06:45

1 Answers1

7

I'll be using $\equiv$ between non-integers to denote that the two sides differ by a multiple of the modulus $b^k$.

The map is a permutation, that is, bijective, exactly if $\frac12m(m+1)\equiv\frac12n(n+1)$ implies $m=n$ for $0\le m,n\lt b^k$. So assume $\frac12m(m+1)\equiv\frac12n(n+1)$. Adding $\frac18$ yields $\frac12\left(m+\frac12\right)^2\equiv\frac12\left(n+\frac12\right)^2$. Bringing both terms to one side and factoring the difference yields $\frac12\left(m+\frac12+n+\frac12\right)\left(m+\frac12-n-\frac12\right)\equiv0$, that is, $\frac12\left(m+n+1\right)\left(m-n\right)=rb^k$.

Now if $b=2$, since $m+n+1$ and $m-n$ have different parity, at most one of them can contribute factors of $2$. Moreover, since $m,n\lt 2^k$, either factor can contain at most $k$ factors of $2$ unless $m=n$. One factor is divided out by the factor $\frac12$, so the equation cannot be fulfilled unless $m=n$.

This argument doesn't work for $b\ne2$; indeed we can always choose $m=b^k-1$ and $n=0$ to get $k$ factors of $b$ in $n+k+1$, and none of them are divided out.

joriki
  • 238,052