I'm struggling to understand why fib([1,2],F)
finds a second solution, false, with the following clauses and rules:
fib([A,B|C],F) :-
fib([B|C],S),
fib(C,T),
F is (S+T).
fib([A],1).
fib([],0).
According to my logical analysis of fib([1,2],F)
, I should just be getting the result F = 2
. I need some help to understand why Prolog finds a second solution, which is false
.