XXXV OM - III - Task 4

We toss a coin $ n $ times and record the result as a sequence $ (a_1, a_2, \ldots, a_n) $, where $ a_i = 1 $ or $ a_i = 2 $ depending on whether an eagle or a tail appeared in the $ i $-th toss. We assume $ b_j = a_1 + a_2 + \ldots + a_j $ for $ j = 1, 2, \ldots, n $, $ p(n) $ is the probability that the number $ n $ appears in the sequence $ (b_1, b_2, \ldots, b_n) $. Determine $ p(n) $ in terms of $ p(n-1) $ and $ p(n-2) $.