My son gave me the following recurrence formula for $x_n$ ($n\ge2$):
$$(n+1)(n-2)x_{n+1}=n(n^2-n-1)x_n-(n-1)^3x_{n-1}\tag{1}$$ $$x_2=x_3=1$$
The task I got from him:
- The sequence has an interesting property, find it out.
- Make a conjecture and prove it.
Obviously I had to start with a few values and calculating them by hand turned out to be difficult. So I used Mathematica and defined the sequence as follows:
b[n_] := b[n] = n (n^2 - n - 1) a[n] - (n - 1)^3 a[n - 1];
a[n_] := a[n] = b[n - 1]/(n (n - 3));
a[2] = 1;
a[3] = 1;
And I got the following results:
$$ a_4=\frac{7}{4}, \ a_5=5, \ a_6=\frac{121}{6}, \ a_7=103, \ a_8=\frac{5041}{8}, \ a_9=\frac{40321}{9}, \\ a_{10}=\frac{362881}{10}, \ a_{11}=329891, \ a_{12}=\frac{39916801}{12}, \ a_{13}=36846277, \ a_{14}=\frac{6227020801}{14}\dots$$
Numbers don't make any sense but it's strange that the sequence produces integer values from time to time. It's not something that I expected from a pretty complex definition like (1).
So I decided to find the values of $n$ producing integer values of $a_n$. I did an experiment for $2\le n \le 100$:
table = Table[{i, a[i]}, {i, 2, 100}];
integers = Select[table, (IntegerQ[#[[2]]]) &];
itegerIndexes = Map[#[[1]] &, integers]
...and the output was:
{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89, 97}
Conjecture (pretty amazing, at least to me):
$a_n$ is an integer if and only if $n$ is prime.
Interesting primality test, isn't it? The trick is to prove that it's correct. I have started with the substitution:
$$y_n=n x_n$$
...which simplifies (1) a bit:
$$(n-2)y_{n+1}=(n^2-n-1)y_n-(n-1)^2y_{n-1}$$
...but I did not get much further (the next step, I guess, should be rearrangement).
The given difference equation can be solved in the following way. We have for $n\ge 3$, $$ (n-2)(y_{n+1}-y_n) = (n-1)^2(y_n-y_{n-1}),\\ \frac{y_{n+1}-y_n}{n-1}=(n-1)\frac{y_{n}-y_{n-1}}{n-2}. $$ If we let $\displaystyle z_n=\frac{y_{n}-y_{n-1}}{n-2}$, it follows that $$ z_{n+1}=(n-1)z_n=(n-1)(n-2)z_{n-1}=\cdots =(n-1)!z_3=(n-1)!\frac{3x_3-2x_2}{1}=(n-1)! $$ This gives $$ y_{n+1}-y_n=(n-1)(n-1)!=n!-(n-1)!, $$ hence $y_n = nx_n = (n-1)!+c$ for some $c$. Plugging $n=2$ yields $2=1!+c$, thus we have that $$\displaystyle x_n =\frac{(n-1)!+1}{n}.$$