The claimed maximal value is achieved at
a1=a2=⋯=a2016=1,a2017=2017a2016+⋯+a0=1−20171,a2018=2017a2017+⋯+a1=1−201721.
Now we need to show that this value is optimal. For brevity, we use the notation
S(n,k)=an−1+an−2+⋯+an−kfor nonnegative integers k⩽n.
In particular, S(n,0)=0 and S(n,1)=an−1. In these terms, for every integer n⩾2 there exists a positive integer k⩽n such that an=S(n,k)/k. For every integer n⩾1 we define
Mn=1⩽k⩽nmaxkS(n,k),mn=1⩽k⩽nminkS(n,k),andΔn=Mn−mn⩾0.
By definition, an∈[mn,Mn] for all n⩾2; on the other hand, an−1=S(n,1)/1∈[mn,Mn]. Therefore,
a2018−a2017⩽M2018−m2018=Δ2018,
and we are interested in an upper bound for Δ2018.
Also by definition, for any n>2, we have Δn⩽nn−1Δn−1.
Proof. Choose positive integers k,ℓ⩽n such that Mn=S(n,k)/k and mn=S(n,ℓ)/ℓ. We have S(n,k)=an−1+S(n−1,k−1), so
k(Mn−an−1)=S(n,k)−kan−1=S(n−1,k−1)−(k−1)an−1⩽(k−1)(Mn−1−an−1),
since S(n−1,k−1)⩽(k−1)Mn−1. Similarly, we get
ℓ(an−1−mn)=(ℓ−1)an−1−S(n−1,ℓ−1)⩽(ℓ−1)(an−1−mn−1).
Since mn−1⩽an−1⩽Mn−1 and k,ℓ⩽n, the obtained inequalities yield
Mn−an−1⩽kk−1(Mn−1−an−1)⩽nn−1(Mn−1−an−1)andan−1−mn⩽ℓℓ−1(an−1−mn−1)⩽nn−1(an−1−mn−1).
Therefore,
Δn=(Mn−an−1)+(an−1−mn)⩽nn−1((Mn−1−an−1)+(an−1−mn−1))=nn−1Δn−1.
Back to the problem, if an=1 for all n⩽2017, then a2018⩽1 and hence a2018−a2017⩽0. Otherwise, let 2⩽q⩽2017 be the minimal index with aq<1. We have S(q,i)=i for all i=1,2,…,q−1, while S(q,q)=q−1. Therefore, aq<1 yields aq=S(q,q)/q=1−q1.
Now we have S(q+1,i)=i−q1 for i=1,2,…,q, and S(q+1,q+1)=q−q1. This gives us
mq+1=1S(q+1,1)=q+1S(q+1,q+1)=qq−1andMq+1=qS(q+1,q)=q2q2−1
so Δq+1=Mq+1−mq+1=(q−1)/q2. Denoting N=2017⩾q and using Claim 1 for n=q+2,q+3,…,N+1 we finally obtain
ΔN+1⩽q2q−1⋅q+2q+1⋅q+3q+2⋯N+1N=N+11(1−q21)⩽N+11(1−N21)=N2N−1
as required.
Comment 1. One may check that the maximal value of a2018−a2017 is attained at the unique sequence, which is presented in the solution above.
Comment 2. An easier question would be to determine the maximal value of ∣a2018−a2017∣. In this version, the answer 20181 is achieved at
a1=a2=⋯=a2017=1,a2018=2018a2017+⋯+a0=1−20181.
To prove that this value is optimal, it suffices to notice that Δ2=21 and to apply Claim 1 obtaining
∣a2018−a2017∣⩽Δ2018⩽21⋅32⋯20182017=20181.