Class assignment

i didn’t understood how the output came

You are given two numbers say a and b, and a number n specifying the number of digits of the number to be formed. The rule is to not have consecutive b’s, you can do alternate a’s and b’s or consecutive a’s.
For example, for n=1, 2 possibilities i.e. a and b
for n=2, 3 possibilities i.e. aa, ab, ba.
for n=3, 4 possibilities i.e. aaa, aba, aab, bab, baa.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.