AI Practical – 1
Que 1. Implement the following.
Define a predicate brother(X,Y) which holds iff X and Y are brothers.
Define a predicate cousin(X,Y) which holds iff X and Y are cousins.
Define a predicate grandson(X,Y) which holds iff X is a grandson of Y.
Define a predicate descendent(X,Y) which holds iff X is a descendent of Y.
Consider the following genealogical tree:
father(a,b).
father(a,c).
father(b,d).
father(b,e).
father(c,f).
Say which answers, and in which order, are generated by your definitions for
the following queries
in Prolog:
?- brother(X,Y).
?- cousin(X,Y).
?- grandson(X,Y).
?- descendent(X,Y).
Que 2. Implement the following programs.
1) Implement Factorial and Fibonacci of given numbers.
2) Find maximum of 3 numbers
3) Find minimum of 3 numbers.
4) Check given number is even/odd.
5) Check given number is positive/negative
6) Calculate Pailindrom of given number.