Let T(n) be the number of ways in which tail never appears three consecutive times in n tosses. We can break down the possible outcomes of the first n-1 tosses into three cases:
-
The first n-1 tosses end in H (heads). The nth toss can be either H or T (tails). Thus, there are T(n-1) ways to achieve this.
-
The first n-2 tosses end in TH. The nth toss must be H to avoid three consecutive tails. Thus, there are T(n-2) ways to achieve this.
-
The first n-3 tosses end in TTH. The nth toss must be H and the (n-1)th toss must be T. Thus, there are T(n-3) ways to achieve this.
Since these cases are mutually exclusive and exhaustive, the total number of ways in which tail never appears three consecutive times in n tosses is:
T(n) = T(n-1) + T(n-2) + T(n-3)
The base cases are:
T(1) = 2 (H or T) T(2) = 4 (HH, HT, TH, TT) T(3) = 7 (HHH, HHT, HTH, THH, THT, HTT, TTT)
Using these base cases and the recurrence relation, we can compute T(n) for any value of n.
For example, T(4) = T(3) + T(2) + T(1) = 7 + 4 + 2 = 13.
Therefore, the number of ways in which tail never appears three consecutive times in n tosses is T(n), where T is defined recursively by T(n) = T(n-1) + T(n-2) + T(n-3) with base cases T(1) = 2, T(2) = 4, and T(3) = 7.