a) Write n=ab, where a and b both are integers greater than 1, and let a1=a2=⋯=an−1=a and an=0. The sum a1+a2+⋯+an=a⋅(n−1) is clearly not divisible by n. Consider any positive integer k≤n: If k≤n−b, then ak+ak+1+⋯+ak+b−1 is divisible by n; otherwise, ak+ak+1+⋯+ak+b is divisible by n.
b) Suppose, if possible, that for each positive integer k≤p there exists a positive integer ℓ≤p such that ak+ak+1+⋯+ak+ℓ−1 is divisible by p; to make a choice, let f(k) be the least such ℓ (any choice will do). Notice that f(k)≤p−1, since ak+ak+1+⋯+ak+p−1=a1+a2+⋯+ap is not divisible by p.
Define integers 0=k0<k1<k2<⋯<kp such that ki+1−ki≤p−1, i=0,1,…,p−1, and
aki+1+aki+2+⋯+aki+1≡0(modp),i=0,1,…,p−1.
The ki are recursively defined by ki+1=ki+f(ki−p⌊ki/p⌋+1), i=0,1,…,p−1.
Consider any integers m and n such that 0≤m<n≤p. Since ki+1−ki≤p−1 for all i, it follows that kn−km≤(n−m)(p−1)≤p(p−1). Moreover,
akm+1+akm+2+⋯+akn=i=m∑n−1(aki+1+aki+2+⋯+aki+1)≡0(modp).(∗)
Amongst the p+1 integers k0,k1,k2,…,kp, there exist two, say km<kn, such that km≡kn(modp). Then
akm+1+akm+2+⋯+akn=pkn−km⋅(a1+a2+⋯+ap)≡0(modp),
since (kn−km)/p is a positive integer less than p, the sum a1+a2+⋯+ap is not divisible by p, and p is prime. This contradicts (∗) and concludes the proof.