Since n is a composite number, we have k≥3.
Let d2=p be the smallest prime that divides n. We show by induction that
dj=2j(j−1)p−2(j−2)(j+1),j=1,2,…,k.
This is clearly true for j=1 and the induction step follows from dj−dj−1=(j−1)(d2−d1)=(j−1)(p−1) and 1+2+3+⋯+(j−1)=2j(j−1).
If we apply this formula to dk−1=pn=d2dk and multiply by 2p, we get
⇔⇔(k−1)(k−2)p2−(k−3)kp=k(k−1)p−(k−2)(k+1)(k−1)(k−2)p2−2(k−2)kp+(k−2)(k+1)=0(k−1)p2−2kp+(k+1)=0.
The solutions of this quadratic equation are p=1 and p=k−1k+1=1+k−12. Since both options are at most 2, the only possibility is p=2, k=3 and n=4. Since n=4 has the required property, this is the only solution.