(1) When n≥2, if a1<a2<a1a2⋯an is classified as A class. The number of a1a2⋯an is denoted by g(n). If a1>a2, then a1a2⋯an is classified as B class. By symmetry, the number of such a1a2⋯an is also g(n). Thus, f(n)=2g(n).
Now we want to find g(n). Denote mk(i) as the k-digit "A wave number" whose last digit is i (i=1,2,3,4), then
g(n)=i=1∑4mn(i).
As a2k−1<a2k, a2k>a2k+1, we have the following 2 cases.
(a) When k is even, mk+1(4)=0, mk+1(3)=mk(4), mk+1(2)=mk(4)+mk(3), mk+1(1)=mk(4)+mk(3)+mk(2).
(b) When k is odd, mk+1(1)=0, mk+1(2)=mk(1), mk+1(3)=mk(1)+mk(2), mk+1(4)=mk(1)+mk(2)+mk(3).
It is obvious that m2(1)=0, m2(2)=1, m2(3)=2, m2(4)=3, then, g(2)=6.
Hence,
m3(1)=m2(2)+m2(3)+m2(4)=6,
m3(2)=m2(3)+m2(4)=5,
m3(3)=m2(4)=3,m3(4)=0.
Therefore
g(3)=i=1∑4m3(i)=14.
On the other hand, since
m4(1)=0,m4(2)=m3(1)=6,
m4(3)=m3(1)+m3(2)=11,
m4(4)=m3(1)+m3(2)+m3(3)=14,
we obtain,
g(4)=i=1∑4m4(i)=31.
In the same way, we could get g(5)=70, g(6)=157, g(7)=353, g(8)=793.
Then, in general, when n≥5,
g(n)=2g(n−1)+g(n−2)−g(n−3).3◯
Now we prove ③ as follows.
Using mathematical induction, we are done when n=5,6,7,8. Suppose ③ holds when for 5, 6, 7, 8..., n now consider the case for n+1. When n is even, from (a), (b), we have
mn+1(4)=0,mn+1(3)=mn(4),
mn+1(2)=mn(4)+mn(3),
mn+1(1)=mn(4)+mn(3)+mn(2).
As mn(1)=0, then
g(n+1)=i=1∑4mn+1(i)=2(i=1∑4mn(i))+mn(4)−mn(2)
=2g(n)+mn(4)−mn(2).
Since
mn(4)=mn−1(1)+mn−1(2)+mn−1(3)+0=i=1∑4mn−1(i)=g(n−1),
mn(2)=mn−1(1)=mn−2(4)+mn−2(3)+mn−2(2)+0=g(n−2).
We obtain,
g(n+1)=2g(n)+g(n−1)−g(n−2).
On the other hand, when n is odd, g(n+1)=∑i=14mn+1(i).
Since mn+1(1)=0,mn+1(2)=mn(1),mn(4)=0,
mn+1(3)mn+1(4)=mn(1)+mn(2),=mn(1)+mn(2)+mn(3),
then,
g(n+1)=i=1∑4mn+1(i)=2i=1∑4mn(i)+mn(1)−mn(3)=2g(n)+mn(1)−mn(3).
Since
mn(1)=mn−1(4)+mn−1(3)+mn−1(2)+0=g(n−1),
mn(3)=mn−1(4)=mn−2(1)+mn−2(2)+mn−2(3)+0=g(n−2).
We get
g(n+1)=2g(n)+g(n−1)−g(n−2).
Hence, ③ holds for n+1. By mathematical induction, ③ holds when n≥5.
From ③,
g(9)=2g(8)+g(7)−g(6)=1782,
g(10)=2g(9)+g(8)−g(7)=4004.
Thus,
f(10)=2g(10)=8008.
(2) Now consider the sequence of remainders of {g(n)} divided by 13. From ③, when n=2,3,4,…,14,15,16,17,…, the corresponding remainders are 6, 1, 5, 5, 1, 2, 0, 1, 0, 1, 1, 3; 6, 1, 5, 5, ...
Therefore, when n≥2, the sequence of remainders is a periodic sequence whose minimum period is 12. As
2008=12×167+4,
we get
g(2008)≡5(mod13).
Therefore,
f(2008)≡10(mod13).