Let n be a positive integer. Let s:N→{1,…,n} be a function such that n divides m−s(m) for all positive integers m. Let a0,a1,a2,… be a sequence such that a0=0 and ak=ak−1+s(k) for all k≥1.
Find all n for which this sequence contains all the residues modulo (n+1)2.Proposed by N.V. Tejaswi abstract algebranumber theory