:- module(_, [fib/2], [assertions,regtypes,nativeprops]).

:- entry fib(X,Y) : num * term.
:- pred fib(M, N) : num * term.
fib(M,N) :-
	fib_(M,N).

:- pred fib_(M, N) : num * term => num * num.
fib_(N,F):-
        fibaux(N,0,1,F).

:- pred fibaux(N, Fact, Post, F) : num * num * num * term => num * num * num * num.
fibaux(0, Fact, _Fpost, Fact) :- !.
fibaux(N, Fact, Fpost, F) :-
        N1 is N - 1,
        Nfib is Fact + Fpost,
        fibaux(N1, Fpost, Nfib, F).

