Convert loop REPEAT to While

GROUPS:
 Hi, I write to ask if there is any way to convert a repeat loop that was used in modula in Mathematica a while since I've tried but if successful, here is the code in my attempt modula and conversion to MathematicaFirst code in Modula-2PROCEDURE ValAbs(x,y:CARDINAL):CARDINAL;BEGINIF x>y THEN RETURN x-y ELSE RETURN y-x END;END ValAbs;PROCEDURE Valido(k:CARDINAL):BOOLEAN;VAR i:CARDINAL;BEGINFOR i:=1 TO k-1 DO IF (X=X)OR (ValAbs(X,X)=ValAbs(i,k))THEN RETURN FALSE END END; RETURN TRUE END Valido;PROCEDURE Reinas(k: CARDINAL);BEGINIF k>n THEN RETURN END;X:=0;REPEATINC(X);IF Valido(k) THEN IF  k<>n THEN  Reinas(k+1) ELSE exito:= TRUE END END UNTIL (X=n) OR exito; END Reinas;Now my translation a Mathematica ValAbs[x_, y_] := If[x > y, Return[x - y], Return[y - x]]; valido[k_] := Module[{i}, For[i = 1, i < k - 1, i++,    If[     Or[      x[[i]] == x[[k]], ValAbs[x[[i]], x[[k]]] == ValAbs[i, k]],     Return[False]     ]    ];   Return[True]  ];Reinas[k_] := Module[{}, If[k > n, Return["error"]];  x[[k]] = 0;  While[ x[[k]] !=  n && Not[exito],   x[[k]]++;   If[valido[k],    If[k != n, Reinas[k + 1], exito = True]]]]n = 5;x = Table[0, {n}]exito = False;Reinas[1]xThe value de x es {1,1,2,2,3} when it should be other.