We claim that the only possible sequences are the following:
* an=n−1 for all n, or
* an=2n2+n+k for all n, where k is a fixed nonnegative integer, or
* an={n−12n2+n−2N2−N+2n≤N,n>N, where N is a fixed nonnegative integer.
Let us first verify that each of these sequences satisfies the conditions:
* If an=n−1 for all n, then an−1+n=2n−2=2an is indeed divisible by an.
* If an=2n2+n+k for all n, then an−1+n=2n2−n+k+n=2n2+n+k=an is also divisible by an.
* In the third case, an divides an−1+n for n≤N as in the first case. Next note that aN+1=2(N+1)2+(N+1)−2N2−N+2=2N divides aN+(N+1)=2N. Finally, for n>N+1, we have an=an−1+n as in the second case, so an again divides an−1+n.
Now we prove that these are the only such sequences. First, let ak be an element of the sequence such that ak≥k (if such an element exists). Recall that ak+k+1 has to be a multiple of ak+1. However, since ak+1>ak, we have
2ak+1≥2(ak+1)>2ak+1≥ak+k+1.
So the only possible multiple of ak+1 that ak+k+1 could be is 1⋅ak+1, and it follows that ak+1=ak+k+1. But then ak+1≥k+k+1≥k+1, so we can repeat the argument with k+1 instead of k to show that ak+2=ak+1+k+2, etc. Generally, we get an+1=an+n+1 for all n≥k.
If a1≥1, then we can invoke this observation immediately: an+1=an+n+1 for all n≥1, so
an=an−1+n=an−2+(n−1)+n=⋯=a1+2+3+⋯+(n−1)+n=2n2+n+(a1−1),
which is exactly our second solution.
Suppose finally that a1=0, and let N be the largest index for which aN=N−1; if there is no largest index, then an=n−1 for all n, and we obtain the first solution. Next note that aN+1 has to divide aN+N+1=2N. By our choice of N, we have aN+1=N, and since aN+1>aN=N−1, the only possible value (the only divisor of 2N) for aN+1 is 2N. But then aN+1=2N≥N+1, and we can apply the same observation as before: am+1=am+m+1 for all m≥N, thus
an=an−1+n=⋯=aN+(N+1)+(N+2)+⋯+(N−1)+n==(N−1)+2n2+n−2N2+N=2n2+n−2N2−N+2
for all n>N, which is indeed the third solution.