:- module( _, [gcd/2], [assertions , regtypes , basicmodes , nativeprops] ).

gcd([[num(int(A)),num(int(0))]],[num(int(A))]).
gcd([[num(int(A)),num(int(B))]],[num(int(B))]) :-
        B\=0,
        B=\=0,
        0 is A rem B .
gcd([[num(int(A)),num(int(B))]],[C]) :-
        B\=0,
        B=\=0,
        D is A rem B,
        D\=0,
        D=\=0,
        E is B rem D,
        execute_notrace_1(B,D,E,_1,_2,_3,_4,_5,C,_6) .

execute_notrace_1(_1,A,0,[],_2,_3,_4,_5,num(int(A)),[]).
execute_notrace_1(_1,A,B,C,D,E,F,G,H,I) :-
        B\=0,
        B=\=0,
        J is A rem B,
        execute_notrace_1(A,B,J,C,D,E,F,G,H,I) .


