fibonacci(1,_,Y,Y). fibonacci(N,X,Y,Z) :- N > 1, N1 is N - 1, XY is X + Y, fibonacci(N1,Y,XY,Z). fib :- read(N), fibonacci(N,0,1,Fib), write(Fib).