fibonacci iterative - a problem

From: Grzegorz Rumatowski (grumatow_at_ZERO__SPAMpoczta.onet.pl)
Date: 11/26/03


Date: Wed, 26 Nov 2003 19:35:01 +0100

Hello NewsGroup!

Because a recursive definition of fibonacci predicate has some limitations,
I've defined following iterative predicate:

fib(0,1).
fib(1,1).
fib(N,F) :- N > 1, fib(N,1,1,F)

fib(2,F1,F2,F) :- F is F1 + F2.
fib(N,F1,F2,F) :- N > 2, N1 is N - 1, NF1 is F1 + F2,
    fib(N1,NF1,F1,F).

The problem is: it's not workin' at all. Any ideas?

-- 
G.R.Z.E.C.H.U.: General Robotic Zombie Engineered 
for Calculation and Hazardous Utility
http://republika.pl/grumatow/

JID:grzechur@jabberpl.org || GnuPG KeyID:73DDCA2F @ http://www.keyserver.net/en/