a) Unless otherwise specified, everywhere in part a), ≡ will denote congruence modulo 49. Consider the six cases a=7k±1, 7k±2 and 7k±3.
1. If a=7k+1, with k∈{0,1,...,6}, then an=7kn+1, so an≡1(mod7)
k=0 or n is a multiple of 7. Thus 1∈A1 and 7k+1∈A7 for k∈{1,...,6}.
2. If a=7k−1, with k∈{1,...,7}, then an=(−1)n−1(7kn−1). If n is odd, then an≡1(mod7kn)≡2 which cannot hold as 7∤2. If n is even, then an≡1(mod7kn)≡0 which holds when k=7 or n is a multiple of 14.
Thus a=48∈A2 and 7k−1∈A14 for k∈{1,...,6}.
3. If a=7k+2, with k∈{0,1,...,6}, then an=2n−17kn+2n, so
an≡1(mod2n−17kn+49l)≡1−2n for some integer l.
This implies in a first instance that 7∣(1−2n), i.e. n=3m for some integer m. Then
71−2n=71−23m=7(1−23)(1+23+⋯+(23)m−1)=−m(mod7)
and 2n−1≡23m−1≡4(mod7).
Therefore, if n=3m and k=4, there exists an integer l such that
2n−1kn+7l=71−2n.
This implies a=30∈A3. Moreover, when 7∤n, then any two solutions k and k′ of the equation above differ by a multiple of 7. On the other hand, if 7∣n, any value of k is a solution, so a=7k+2∈A21 for k∈{0,...,6}∖{4}.
4. If a=7k−2, with k∈{1,…,7}, then an=(−2)n−1(7kn−2). If n is odd, then an=1⟺2n−17kn=2n+1 which implies that 7∣(1+2n). A short check of the possible values of 1+2n modulo 7 shows that this is not possible. If n is even, then an=1⟺−2n−17kn+49l=1−2n for some integer l. Similarly to the previous case, this implies a=7⋅3−2=19∈A6 and a=7k−2∈A42 for k∈{0,…,6}∖{3}.
5. If a=7k+3, with k∈{0,1,…,6}, then an=3n−17kn+3n, so an=1⟺3n−17kn+49l=1−3n for some integer l. This implies that 7∣(1−3n), i.e. n=6m for some integer m. Then
71−3n=71−36m=7(1−36)(1+36+⋯+(36)m−1)≡mmod7and 3n−1≡5mod7
Therefore, if n=6m and k=4, there exists an integer l such that the equation
3n−1kn+7l=71−3n
holds, so a=31∈A6. As in the previous cases, a=7k+3∈A42 for k∈{0,…,6}∖{4}.
6. If a=7k−3, with k∈{1,…,7}, then an=(−3)n−1(7kn−2). If n is odd, then an=1⟺3n−17kn=3n+1 which implies that 7∣(1+3n). A short check of the possible values of 1+3n modulo 7 shows that this is equivalent to n=6m+3 and then an=1⟺3n−1kn=73n+1, where the right hand side becomes
71+33(2m+1)=7(1+33)(1−33+⋯+(33)2m)≡4(2m+1)mod7,
an=1 becomes 36m+3k(2m+1)=4(2m+1)(mod7), equivalently 6k(2m+1)=4(2m+1)(mod7), which holds for all m when k=3, and for all k when (2m+1)≡0(mod7). Thus a=7⋅3−3=18∈A3 while a=7k−3∈A21 for k∈{1,…,7}∖{3}. If n is even, then an=1⟺−3n−17kn+49l=1−3n for some integer l. Similarly to the previous case, this implies a6=1 for a=7⋅3−2=18 and a42=1 for a=7k−2 and k∈{0,…,6}∖{3}, which was already known from the case of n odd.
b) 2009=49⋅41. From a) it follows that 49 divides a42−1 for all integers a relatively prime to 49. From Fermat's theorem, 41 divides a40−1 for all integers a relatively prime to 41. The least common multiple of 40 and 42 is 840 and thus 2009 divides a840−1 for all integers a relatively prime to 2009. It now suffices to find an integer a such that 2009∣(an−1)⇔840∣n. It is natural to try a∈A42={3,5,10,12,17,24,26,33,38,40,45}. Modulo 41, we have 38≡1, 520≡1 and 105≡1, but n=40 is the least power such that 12n≡1, so n=840 is indeed the least power such that 2009∣(12n−1).