Integers $n$ such that $i(i+1)(i+2) \cdots (i+n)$ is real or pure imaginary
Not an answer, but an equivalence…
As pointed out in the original question, $i(i-1)(i-2)…(i-n)$ landing on the real or imaginary axis implies $\arctan(1)+\arctan(2) + … + \arctan(n)$ is a multiple of $\pi/4$. Since $i(i-1)(i-2)…(i-n)$ is a Gaussian integer, this also implies that its magnitude is an integer and so $(1+1)(1+4) \cdots (1+n^2)$ is a perfect square.
On the other hand, if $\arctan(1)+\arctan(2) + … + \arctan(n)$ is a multiple of $\pi/4$ then $i(i-1)(i-2)…(i-n)$ lands on the real or imaginary axis and so this statement about the sum of tangents is equivalent to the original question.
In a similar way, if $(1+1)(1+4) \cdots (1+n^2)$ is a perfect square then set $k := \sqrt{(1+1)(1+4) \cdots (1+n^2)}$ and note that the Gaussian integer $\frac{i(i-1)(i-2)…(i-n)}{k}$ has length 1. Since the only Guassian integers of length 1 are $\pm 1, \pm i$ then $i(i-1)(i-2)…(i-n)$ lies on the real or imaginary axis.
In other words, the following are equivalent.
- $i(i-1)(i-2)…(i-n)$ lies on the real or imaginary axis,
- $\arctan(1)+\arctan(2) + … + \arctan(n)$ is a multiple of $\pi/4$,
- $(1+1)(1+4) \cdots (1+n^2)$ is a perfect square.
Not an answer, but an observation that is far too long for a comment.
It's a well known fact that $$z(z+1)\ldots (z+n-1) = \sum_{k=0}^{n}{n \brack k}z^k$$
Where ${n \brack k}$ denotes an unsigned Stirling number of the first kind. ${n \brack k}$ counts the number of permutations of $n$ elements that are the product of $k$ disjoint cycles.
Thus $$i(i+1)\ldots(i+n-1) = \sum_{k=0}^{n}{n \brack k}i^k$$
Hence
$$\operatorname{Re}\left\{i(i+1)\ldots (i+n-1)\right\} = \sum_{k \equiv 0 \operatorname(mod) 4}{n \brack k} - \sum_{k \equiv 2 \operatorname(mod) 4} {n \brack k}$$
and
$$\operatorname{Im}\left\{i(i+1)\ldots (i+n-1)\right\} = \sum_{k \equiv 1 \operatorname(mod) 4}{n \brack k} - \sum_{k \equiv 3 \operatorname(mod) 4} {n \brack k}$$
Where our notation makes sense since ${n \brack k} = 0$ when $k < 0$ or $k > n$.
We then have the following combinatorial interpretation of your problem.
$i(i+1)\ldots (i+n-1)$ is purely real iff the number of permutations of $n$ elements with number of disjoint cycles congruent to 1 modulo 4 equals the number of permutations of $n$ elements with number of disjoint cycles congruent to 3 modulo 4. A similar statement can be made for the case when $i(i+1)\ldots (i+n-1)$ is purely imaginary.
Now let $$A_0(n) = \sum_{k \equiv 0 \operatorname(mod) 4}{n \brack k}$$ $$A_1(n) = \sum_{k \equiv 1 \operatorname(mod) 4}{n \brack k}$$ $$A_2(n) = \sum_{k \equiv 2 \operatorname(mod) 4}{n \brack k}$$ $$A_3(n) = \sum_{k \equiv 3 \operatorname(mod) 4}{n \brack k}$$
Unsigned Stirling numbers of the first kind satisfy the recurrence $${n \brack k} = (n-1){n-1 \brack k} +n{n-1 \brack k-1}$$
Plugging this into the equation for $A_0(n)$ gives us the recurrence $$A_0(n) = (n-1)\sum_{k \equiv 0 \operatorname(mod) 4}{n-1\brack k} + \sum_{k \equiv 0 \operatorname(mod) 4}{n-1 \brack k-1} =$$ $$(n-1)\sum_{k \equiv 0 \operatorname(mod) 4}{n-1 \brack k} + \sum_{k \equiv 3 \operatorname(mod) 4}{n-1 \brack k} =$$ $$(n-1)A_0(n-1) - A_3(n-1)$$
Plugging the recurrence into each equation gives us the system of recurrences $$A_0(n) = (n-1)A_0(n-1) - A_3(n-1)$$ $$A_1(n) = (n-1)A_1(n-1) - A_0(n-1)$$ $$A_2(n) = (n-1)A_2(n-1) - A_1(n-1)$$ $$A_3(n) = (n-1)A_3(n-1) - A_2(n-1)$$
with initial condition $$A_0(0) = 1\mbox{, } A_1(0) = A_2(0) = A_3(0) = 0$$
Letting $X(n) = A_{2}(n) - A_{0}(n)$ and $Y(n) = A_3(n) - A_1(n)$, we can derive the following system of recurrence for them by subtracting recurrences for the $A_{i}$'s.
$$X(n) = (n-1)X(n-1) - Y(n-1)$$ $$Y(n) = (n-1)Y(n-1) + X(n-1)$$
with initial condition $X(0) = -1$, $Y(0) = 0$.
If we can show that for $n \geq 5$, $X(n) \neq 0$ and $Y(n) \neq 0$ then we will have proven that $i(i+1)\ldots (i+n-1)$ cannot be purely real or purely imaginary for $n \geq 5$. This is where I'm stuck. I hope someone finds this direction helpful in solving this problem.
An element of $\Bbb Q[i]^\times$ is real or imaginary if and only if its image in the quotient $G = \Bbb Q[i]^\times / \langle i, \Bbb Q^\times \rangle$ is trivial.
Since $\Bbb Z[i]$ has unique factorization, $(\Bbb Q[i]^\times,\times)$ is the direct product of :
- the unit group $\{1,i,-1,-i\}$, which is annihilated in the quotient
- $p^\Bbb Z$ for $p \equiv 3 \pmod 4$ , again annihilated
- $\mathfrak p^\Bbb Z \overline{\mathfrak p}^\Bbb Z$ for $p \equiv 1 \pmod 4$ where $\mathfrak p \overline{\mathfrak p} = p$ is annihilated
- $(1+i)^\Bbb Z$ where $(1+i)^2 = 2i$ is annihilated
Hence the quotient $G$ is isomorphic to $(\bigoplus_{p \equiv 1 \pmod 4} \Bbb Z) \oplus \Bbb Z/2\Bbb Z$, and we can look component by component at what $i(i+1)(i+2)\ldots(i+n)$ is.
We do so by looking at the prime decomposition of its norm. A norm divisible by $2$ means that we have a factor of $(1+i)$, and two of them cancel each other. Otherwise, a norm divisible by $p$ means that we have one of the two factors $\mathfrak p$ or $\overline{\mathfrak p}$. So $p$ comes in two "colors" that cancel each other. Both "colors" appear periodically with period $p$, and if we first see the prime $p$ at $i+k$, then the opposite color always appears at $i+(p-k)$.
Looking at the first few prime factorisations of $(1+k^2)$, and coloring the first occurence of a prime blue, we have :
$2,\quad \color{blue}{5},\quad 2.\color{red}{5},\quad \color{blue}{17}, \quad 2.\color{blue}{13}, \quad \color{blue}{37},\quad 2.\color{blue}{5^2}, \quad \color{red}{5.13},\quad 2.\color{blue}{41},\quad \color{blue}{101}, \quad 2.\color{blue}{61}, \quad \color{blue}{5.29},\quad 2.\color{red}{5.17},\quad \ldots$.
The product of the first three terms cancel completely, and it follows that $(i+1)(i+2)(i+3)$ is real or pure imaginary. Then, by $k=10$ we can't get rid of the $\color{blue}{101}$ before we get to $k=91$. By then, we will just have introduced some $\color{blue}{8101}$, which we can remove only at $k=8011$, and so on. So things are looking grim !
This suggests that we are never even close to have a complete cancellation again, but I don't see any simple argument proving it.
If we look at the product of the first $n$ terms and we find a prime $p>2n$, then if it occured at $k \le n$, it only occurs later at $p-k > 2n-k \ge n$, so it is not cancelled. Suppose we have a cancellation, and let us estimate the number of times a prime appears in the factorisation of $\prod(1+k^2)$.
Since about $2/p^d$ values of $k$ give $1+k^2$ divisible by $p^d$, we get something like $\sum_{d \ge 1} (2np^{-d} + O(1))$. If we want to have a complete cancellation, there is a maximum value of $d$ : at each level, one color can have at most $1$ term more than the other. If a level occurs in both colors, then $2n \ge p^d$, so that $d \le \log{2n}/\log p$. This gives us an upper limit on $d$ of $2\log{2n}/\log p$, and so the total number of times that $p$ appears is $N(n,p) = \sum_{d=1}^{2\log{2n}/\log p} (2np^{-d} + O(1)) = 2n/(p-1) + O(\log n / \log p)$.
Now, we look at the contribution of all the primes less than $2n$ : $L = \log (\prod_{p=2}^{2n-1}) p^{N(n,p)} 1_{prime}(p)) = \sum_{p=2}^{2n-1} N(n,p) \log p 1_{prime}(p)$.
Since number $p$ is prime with a square root of $-1$ about $1/{2\log p}$ of the time, we get $L \approx \int_2^{2n} N(n,p)\log p / (2 \log p) dp = \int_2^{2n} N(n,p)/2 = n \log(2n-1) + O(\log n Li(2n)) = n \log n + O(n)$
Meanwhile, we should have $L = \log \prod_{k=1}^n (1+k^2) = \sum_{k=1}^n \log(k^2+1) = 2\sum_{k=1}^n \log k + O(1) = 2n\log n + O(n)$
This shows that the contribution of primes $p \ge 2n$ is asymptotically half of the whole thing. So lots of them have to appear.