Class assignment doubt

Please provide any hint
thanks

hello @vatsal50

one way to solve this problem is to generate all possible n lenght string and count those string in ur answer that are satisfying the given constraint.

another way is as follows->
let say we need to form n digit number with following constraints
a) we can use only digit a and b.
b) no 2 b two come together.

now lets say ways(n) is a function which tells us number of such n digit number.
ways(n) =

if we place a at nth position then  total number of ways for this case will be ways(n-1)

if we place b at nth position then n-1 th position must contain a so  total number of ways for this case will be ways(n-2)

on adding both the cases we get

ways(n)=ways(n-1)+ ways(n-2)
clearly this sequence is fibonnacci

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.