alexarcan

Lab2AIF

Mar 3rd, 2016
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.34 KB | None | 0 0
  1. maximum(X,Y,X):-
  2.     X>=Y.
  3. maximum(X,Y,Y):-
  4.     X<Y.
  5.  
  6. min(X,Y,X):-
  7.     X=<Y,
  8.     !.
  9. min(_,Y,Y).
  10.  
  11. abs2(X,X) :- X >= 0, !.
  12. abs2(X,Y) :- Y is -X.
  13.  
  14. fib(0,X):-X is 0.
  15. fib(1,X):-X is 1.
  16. fib(X,Y):-
  17.     X>=2,
  18.     X_Prime is X-1,
  19.     X_PrimeTwo is X-2,
  20.     fib(X_Prime,Y_Prime),
  21.     fib(X_PrimeTwo,Y_PrimeTwo),
  22.     Y is Y_Prime+Y_PrimeTwo.
  23.  
  24. divisor(X,Y,Z):-
Add Comment
Please, Sign In to add comment