You are on page 1of 1

Write a program to find FIBONACCI series.

input will tell that how many number you want as output: predicates go fibo(integer,integer,integer) clauses go:write("enter no="), readint(X), fibo(0,1,X). fibo(_,_,1):write("1"),nl,write("1"). fibo(A,B,C):B<C, write(B),nl, D=A+B, fibo(B,D,C). Or fib(0, 1). fib(1, 1). fib(X, Y):X > 1, X1 is X - 1, X2 is X - 2, fib(X1, Z), fib(X2, W), Y is W + Z.

You might also like