Advertisement
dzieciol

prolog 2

May 21st, 2018
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.34 KB | None | 0 0
  1. mul(0,_,0):-!.
  2. mul(X,_,_):- X < 0,!.
  3. mul(1,X,X).
  4. mul(X,Y,R) :- X1 is X-1, mul(X1,Y,R1),!, R is R1 + Y.
  5.  
  6. % silnia(0,1):-!.
  7.  
  8. % silnia(X,W) :- X1 is X-1, silnia(X1,W1), W is X * W1.
  9.  
  10. % silnia (X,X):-!.
  11.  
  12. % silnia(X,W):- silnia(1,X,W).
  13.  
  14. silnia(X,Y,Z):- X>Y, !.
  15.  
  16. silnia(X,Y,W) :-
  17.     X1 is X+1,
  18.     W1 is W * X,
  19.     silnia(X1,Y,W1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement