Prolog program to find Fibonacci series

  • 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).
    
    

    2 thoughts on “Prolog program to find Fibonacci series

    Leave a Reply

    Please log in using one of these methods to post your comment:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google photo

    You are commenting using your Google account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s