TITLE: Does $(n+1)(n-2)x_{n+1}=n(n^2-n-1)x_n-(n-1)^3x_{n-1}$ with $x_2=x_3=1$ define a sequence that is integral at prime indices?
QUESTION [44 upvotes]: 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).

REPLY [3 votes]: My process to find the solution probably involves too far a leap of faith, but I will post it anyway.
First, after writing out at least 8 terms, I noticed that, apart from integers, all terms are of the form $a_n=?/n$. So naturally I turned towards the sequence $b_n\equiv a_n\cdot n$, which goes like $3, 7, 25, 121, 721, 5041, 40321, \dots$.
Now my intuition senses the number sequence $504*, 4032*$, which resembles the factorial of 7&8, moreover, a lot of them seems to end in $1$. So I made a further conjecture that  

$$a_n=\frac{(n-1)!+1}{n}.$$

A quick check of Wilson's theorem shows that it is compatible with the original conjecture. Thus, we seem to be on the right track. This can be easily proved by induction.