0% found this document useful (0 votes)
32 views5 pages

AIM:-To Check The Relation Between Two Number: Prolog Lab

The document is a Prolog program written by Akanksha from CSE-A(8101). It contains code to check the relations between two numbers, generate the Fibonacci series for a given number, and calculate the factorial of a given number. The code includes domains, predicates, and clauses to define the logic for each program.

Uploaded by

Anjali Rai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

AIM:-To Check The Relation Between Two Number: Prolog Lab

The document is a Prolog program written by Akanksha from CSE-A(8101). It contains code to check the relations between two numbers, generate the Fibonacci series for a given number, and calculate the factorial of a given number. The code includes domains, predicates, and clauses to define the logic for each program.

Uploaded by

Anjali Rai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PROLOG LAB

AKANKSHA
CSE-A(8101)

AIM:-To check the relation between two number

domains
A,B=INTEGER.
predicates
bigger(A,B)
smaller(A,B)
equal(A,B)
notequal(A,B)
clauses
bigger(A,B):- A>B ,write("A is greater than B").
smaller(A,B):- A<B , write("B is greater than A").
equal(A,B):- A=B ,write("A is equal to B").
notequal(A,B):- A><B ,write("A is not equal to B").

OUTPUT
PROLOG LAB
AKANKSHA
CSE-A(8101)

AIM:-To generate the Fibonacci series.


domains
X=INTEGER
predicates
go
fib(X,X)
clauses
go:-
write("enter any number:"),
readint(B),
A=0,
fib(B,A).
fib(0,A):-
write("fib is:",A).
fib(B,A):-
C=A+B,
D=B-1,
fib(D,C).
PROLOG LAB
AKANKSHA
CSE-A(8101)

OUTPUT
PROLOG LAB
AKANKSHA
CSE-A(8101)

AIM:-To find the factorial of a number


domains
X=INTEGER
predicates
go
fact(X,X)
clauses
go:-
write("enter any number:"),
readint(B),
A=1,
fact(B,A).
fact(0,A):-
write("fact is:",A).
fact(B,A):-
C=A*B,
D=B-1,
fact(D,C).
PROLOG LAB
AKANKSHA
CSE-A(8101)

OUTPUT

You might also like