1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% 991202 Slim Abdennadher, LMU
5 %% ported to hProlog by Tom Schrijvers
7 :- module(fib,[main/0,main/1]).
9 :- use_module(library(chr)).
13 %% fib(N,M) is true if M is the Nth Fibonacci number.
15 %% Top-down Evaluation with Tabulation
17 fib(N,M1), fib(N,M2) <=> M1 = M2, fib(N,M1).
23 fib(N,M) ==> N > 1 | N1 is N-1, fib(N1,M1), N2 is N-2, fib(N2,M2), M is M1 + M2.
33 write(bench(fib ,N,Time, 0, hprolog)),write('.'), nl.