fork(1) download
  1. fib(0, 0).
  2. fib(1, 1).
  3. fib(N, F) :- X is N - 1, Y is N - 2, fib(X, A), fib(Y, B), F is A + B.
  4.  
  5. fib_sequence(A,B,[]) :- A > B.
  6. fib_sequence(A,B,[H|T]) :- A =< B , fib(A, H), AA is A + 1, fib_sequence(AA, B, T).
  7.  
  8. :- fib_sequence(1,5,Output), write(Output).
Success #stdin #stdout #stderr 0.02s 6160KB
stdin
Standard input is empty
stdout
[1, 1, 2, 3, 5]
stderr