I'm trying to make my own implementation of the fibonacci sequence. This is what I have:
fibo2(N, F) :-
fibo2(0, 1, 0, N, F).
fibo2(N-F, F, N-1, N, F).
fibo2(P, S, C, N, F) :-
C < N,
T is S,
S1 is P + S,
C1 is C + 1,
fibo2(T, S1, C1, N, F).
I know there are other implementations but I dont know why this isnt working. When I do a trace with fibo2(3, 2)
I think this call should throw true:
fibo2(1, 2, 2, 3, 2) ? creep
But it returns false... Some help would be appreciated
"fibo2(N, F):- % F is N-th Fibonacci number, indexed base 1"
should have been there. - Will Ness