Thanks to Lurker!
I wasn't using the proper algorithm. I thought of finding GCD of two numbers and then GCD of the result and the next one, but I am not sure why I got confused that this won't work.
Anyway, here is the code:
gcd(0,X,X):- X > 0, !.
gcd(X,Y,Z):- X>=Y, X1 is X -Y, gcd(X1,Y,Z).
gcd(X,Y,Z):- X<Y, X1 is Y-X, gcd(X1,X,Z).
gcdL([H,H1|T],Z):-gcd(H,H1,X),gcdL([X|T],Z).
gcdL([H1,H2],Z):-gcd(H1,H2,Z).
And for the curious here is the retarded approach I was trying to achieve. And I was almost there as the first answer the script gives is correct, but it continues to backtrack. Anyway it's ugly, long, hard and inefficient:
minel([X],X).
minel([H,H1|T],X):-H>H1,minel([H1|T],X).
minel([H,H1|T],X):-H=<H1,minel([H|T],X).
gcdL(L,X):-gcdL(L,X,1).
gcdL(L,X,C):-minel(L,M),C<M,delAll(L,C),Temp is C,C1 is C + 1,gcdL(L,R,C1),X is max(Temp,R).
gcdL(L,X,C):-minel(L,M),C1 is C + 1,C1=<M,gcdL(L,X,C1).
gcdL(L,X,C):-minel(L,M),C=:=M,X is 1.
delAll([T],X):- 0 is mod(T,X).
delAll([H|T],X):- 0 is mod(H,X),delAll(T,X)
Note taken: First find the most proper algorithm, then try to script the problem.