# Number of ways to flip a coin 10 times with no consecutive heads

$\begingroup$ I know there has been an answer for a while but I think I ‘ve got an easier approach and maybe it ‘s worth writing .
sol I will show the solution inductive : lease ‘s assume after $i$ flips we had $n_ { i, heat content }$ ways to end with a head and $n_ { i, metric ton }$ ways to end with a tail .
so let ‘s observe the ( n+1 ) thorium interchange :

If the nth was a head we will count the ( n+1 ) th only if it ‘s a tail .
If the nth was a tail we will count the ( n+1 ) th anyhow .
so that means $n_ { i+1, thymine } = \left ( n_ { i, metric ton } + n_ { iodine, planck’s constant } \right )$ and $n_ { i+1, planck’s constant } = n_ { iodine, metric ton }$ .
And we have the basis subject where $n_ { 1, henry } = n_ { 1, deoxythymidine monophosphate } = 1$ then you have now a dainty recursive formula you can use, but let ‘s attempt to make it simpler .
There is many ways to approach this, one of them is with matrices, let ‘s observe the follow matrix :
$\begin { bmatrix } 1 & 1 \\ 1 & 0 \\ \end { bmatrix }$
and the product :

$A. \begin { pmatrix } x_ { 1 } \\ x_ { 2 } \\ \end { pmatrix } = \begin { pmatrix } x_ { 1 } + x_ { 2 } \\ x_ { 1 } \\ \end { pmatrix }$
thus if $\begin { pmatrix } x_ { 1 } \\ x_ { 2 } \\ \end { pmatrix }$ represents the ith sample, $\left ( A. \begin { pmatrix } x_ { 1 } \\ x_ { 2 } \\ \end { pmatrix } \right )$ will represent the ( i+1 ) th try with $x_1$ the count of tails and $x_2$ the issue of heads .
This is specially useful, when we have normality tries : $A * ( A* ( \dots * ( A* \begin { pmatrix } 1 \\ 1 \\ \end { pmatrix } ) ) ) = A^n * \begin { pmatrix } 1 \\ 1 \\ \end { pmatrix }$ then all you in truth need to do is to calculate $A^ { n-1 }$ and multiply it with $\begin { pmatrix } 1 \\ 1 \\ \end { pmatrix }$ then the solution will be the sum of $x_1$ and $x_2$ in the result vector .
One more approach for it, is after observing the fact that the number of tails is the union of the last number of tails and final number of heads and the number of heads is the last issue of tails we can observe how they evolve :
tails : 1, 2, 3, 5, 8, …
heads : 1, 1, 2, 3, 5, …

It is clear that the each number is the total of the last two numbers before it, which is precisely the Fibonacci numbers in definition. so what we are precisely looking for is fib ( n+1 ) + fib ( nitrogen ) = fib ( n+2 ), for fib ( n+1 ) the act of ways to end with stern and fib ( north ) is the issue ways to end with head .
In your shell the answer is fib ( 12 ) = 144 .
P.S. Matrix exponentiation is one of the most celebrated ways to calculate Fibonacci numbers .

reservoir : https://ontopwiki.com
Category : Finance