Optimal Binary Strings Recursion

I am unable to understand this problem. Can someone explain it please?

Hello @Sharleen-Clement-3051084341644767 in this problem u need to tell the count of n length binary string which have no consecutive one.

for example if n=3
then all 3 length string are ->
000
001
010
011
100
101
110
111

total 8 , 3 length strings but 3 of them have consecutive ones(011,110,111) so we wont count them
hence our answer will be 5
if you still have any doubt you can ask here:
Happy Learning!!

I understood that but how did we come up with the solution? I don’t understand the logic behind the code.

@Sharleen-Clement-3051084341644767 could you please share the code which you are trying to do for this so that we can discuss the whole implementation.