1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% 16 June 2003 Bart Demoen, Tom Schrijvers, K.U.Leuven
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 :- module(fibonacci,[]).
9 :- use_module(library(chr)).
11 :- constraints fibonacci/2.
13 %% fibonacci(N,M) is true iff M is the Nth Fibonacci number.
15 %% Top-down Evaluation with effective Tabulation
16 %% Contrary to the version in the SICStus manual, this one does "true"
19 fibonacci(N,M1) # Id \ fibonacci(N,M2) <=> var(M2) | M1 = M2 pragma passive(Id).
21 fibonacci(0,M) ==> M = 1.
23 fibonacci(1,M) ==> M = 1.