Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %первая задача
- p1(X,Y) :- 0 is X mod 2, X=2, Y=2.
- p1(X,Y) :- 0 is X mod 2, X>2 , X1 is X - 2, p1(X1,Y1), Y is Y1 * X.
- p1(X,Y) :- 1 is X mod 2, X=1 ,Y=1.
- p1(X,Y) :- 1 is X mod 2, X>1, X1 is X-2, p1(X1,Y1), Y is Y1*X.
- %вторая задача
- p1(X,Y):-X=0,Y=0.
- p1(X,Y):- X>0,X1 is X div 2, p1(X1, Y1),Y is Y1+X mod 2.
- p(X):- X>=0, p1(X,Y), 0 is Y mod 2.
- %третья задачка
- p1(X,Y):-0 is X mod Y.
- p1(X,Y):- Y*Y=<X,Y1 is Y+1, p1(X,Y1).
- p(X):-X=:=2; X>1 , \+p1(X,2).
Add Comment
Please, Sign In to add comment