PonaFly

Untitled

Sep 15th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.50 KB | None | 0 0
  1. %первая задача
  2. p1(X,Y) :- 0 is X mod 2, X=2, Y=2.
  3. p1(X,Y) :- 0 is X mod 2, X>2 , X1 is X - 2, p1(X1,Y1), Y is Y1 * X.
  4. p1(X,Y) :- 1 is X mod 2, X=1 ,Y=1.
  5. p1(X,Y) :- 1 is X mod 2, X>1,  X1 is X-2, p1(X1,Y1), Y is Y1*X.
  6.  
  7. %вторая задача
  8. p1(X,Y):-X=0,Y=0.
  9. p1(X,Y):- X>0,X1 is X div 2, p1(X1, Y1),Y is Y1+X mod 2.
  10. p(X):- X>=0, p1(X,Y), 0 is Y mod 2.
  11.  
  12. %третья задачка
  13. p1(X,Y):-0 is X mod Y.
  14. p1(X,Y):- Y*Y=<X,Y1 is Y+1, p1(X,Y1).
  15. p(X):-X=:=2; X>1 , \+p1(X,2).
Add Comment
Please, Sign In to add comment