IMO 1992 LL FRG19

Denote by an the greatest number that is not divisible by 3

IMO 1992 LL FRG19

Origin: FRG

Problem

Denote by an the greatest number that is not divisible by 3 and that divides n. Consider the sequence s0 = 0, sn = a1 + a2 + \cdot \cdot \cdot+ an, n \inN. Denote by A(n) the number of all sums sk (0 \leqk \leq3n, k \inN0) that are divisible by 3. Prove the formula A(n) = 3n−1 + 2 \cdot 3(n/2)−1 cos(n\pi/6), n \inN0.