Ok, I know it s really a stupid question, but I can t get it. There is a task where I should find a recursive algorithm of Euclid (gcd). I ve done it for one case, here:
nondeterm nod (integer,integer,integer)
CLAUSES
nod (X,0,X):- !.
nod (0,X,X):- !.
nod (X,0,X):-X>0.
nod (X,Y,G):-Y>0, Z = X mod Y, nod (Y,Z,G).
I need to do another case, where recursion is beginnig from х0, when Xi then calling for function counting Xi+1. It should be sort of it:
PREDICATES
nondeterm nod (integer,integer,integer)
nondeterm nod1 (integer,integer,integer,integer,integer)
CLAUSES
nod(X,Y,Z):- nod1(X,Y,Z,0,0).
nod1 (X,Y,Z,X,Y):- Otvet = Z, write("Otvet=", Otvet, "
"), !.
nod1 (X,Y,X,Y):- nod1 (X,Y,X,Y).
nod1 (X,Y,Z,X1,Y1):-
X1>Y1, X>0, Y>0,
Y2 = X1 mod Y1,
X2 = Y1,
nod1(X,Y,Z,X2,Y2).
但它没有工作。 请帮助我这样做。