Solution :

Put  and . By using of trigonometric formulas

and taking into account that  and , we have  and .

Therefore,  is integer. If we define (mod 5) and (mod 5), then we have  and  modulo 5. Obviously,  is uniquely determined by initial values  and  and is a periodic sequence.

If  then  ,  ,  ,  ,  

If  then  ,  ,  ,  ,  

(Both sequences have a period 4). Finally, a = 1 or 4.