# Sequences with integral variances

This is a companion to my earlier question, Sequences with integral means. This new question is, frankly, not as interesting, but it feels necessary to complete the thought.

Let $V(n)$ be the sequence whose first element is $n$, and from then onward, the next element is the smallest natural number ${\ge}1$ that ensures that the variance of all the numbers in the sequence is an integer. If there is no such number to extend $V(n)$, then it has finite length.

For example, for $n=20$, $V(20) = 20,2,2,4$. When the last element $4$ is added, the mean is $28/4=7$, and the variance sum is $$13^2 + (-5)^2 + (-5)^2 + (-3)^2 = 169+25+25+9 = 228$$ which is divisible by $n=4$ yielding a variance of $57$. (NB: An earlier version of this question divided by $n{-}1$ rather than by $n$; see the comments.) None of the smaller alternatives $1,2,3$ lead to integral variance. The $V(20)$ sequence cannot be extended beyond that terminating $4$, for the attempt to extend leads to a quadratic Diophantine equation with no solution.

Q1. Is it the case that the only infinite sequences are $V(1)=1,1,1,\ldots$ and $V(2)=2,2,2,\ldots$ ?

Q2. Is there nevertheless no upperbound on the length of the longest finite sequence?

Here are some "long" sequences encountered within $n \le 1000$, of lengths $6$, $6$, $8$, and $9$ respectively: $V(61)=61,1,1,1,1,1$; $V(62)=62,2,2,2,2,2$; $V(422)=422,2,2,2,2,2,2,6$; $V(842)=842,2,2,2,2,2,2,2,8$.

-
Dividing by $n-1$, not by $n$? –  Gerry Myerson Nov 3 '13 at 22:18
@GerryMyerson: Yes, dividing by $n-1$. Of course one could define the variance differently, I was just following the typical unbiased estimate of the variance... Perhaps for number-theoretic interest, dividing by $n$ would be more natural? –  Joseph O'Rourke Nov 3 '13 at 22:27
Another unimpeachable source: the Kahn Academy! :-) Review and intuition why we divide by n-1 for the unbiased sample variance. –  Joseph O'Rourke Nov 3 '13 at 22:40
Since this is not a situation of sampling from a distribution, I don't see what an "unbiased estimate" has to do with it. You're free to use whatever formula you want, but you should at least specify it. –  Robert Israel Nov 3 '13 at 23:05
@JosephO'Rourke How about the sequences arising from the elements in oeis.org/A174554? I believe this will answer your second question (there is no upper-bound as one can produce a long string of $2$s). –  Benjamin Dickman Nov 5 '13 at 3:46

The variance of the list $n,1,1,\dots,1$ of length $k$ equals $(k-1)(n-1)^2/k^2$. In particular, if $n\equiv1\pmod k$ then this variance is an integer. It follows that if $n\equiv1\pmod{k!}$, then the sequence $V(n)$ has length at least $k$. This answers Q2: there is no upper bound on the length of such sequences.