augment=Function[{m,v},Module[{i,newm,dim},
dim=Length[m];
i=1;
newm={};
While[i≤dim,
newm=Append[newm,Append[m[[i]],v[[i]]]];
i=i+1
];
newm
]];

sumrows=Function[{r1,r2},Module[{r,i,len},
len=Length[r1];
i=1;
r={};
While[i≤len,
r=Append[r,r1[[i]]+r2[[i]]];
i=i+1
];
r
]];

multrow=Function[{r,x},Module[{newr,i,len},
len=Length[r];
i=1;
newr={};
While[i≤len,
newr=Append[newr,r[[i]]*x];
i=i+1
];
newr
]];

lastvector=Function[m,Module[{v,i,lin,col},
lin=Length[m];
col=Length[m[[1]]];
i=1;
v={};
While[i≤lin,
v=Append[v,m[[i,col]]];
i=i+1
];
v
]];

gauss=Function[{m,v},Module[{mv,i,j,dim},
dim=Length[m];
mv=augment[m,v];
i=1;
While[i<=dim,
mv[[i]]=multrow[mv[[i]],1/mv[[i,i]]];
j=i+1;
While[j≤dim,
mv[[j]]=sumrows[mv[[j]],multrow[mv[[i]],-mv[[j,i]]]];
j=j+1
];
i=i+1
];
i=dim;
While[i≥1,
j=i-1;
While[j≥1,
mv[[j]]=sumrows[mv[[j]],multrow[mv[[i]],-mv[[j,i]]]];
j=j-1
];
i=i-1
];
lastvector[mv]
]];

m={{2,-1,1},{1,0,1},{-1,1,1}}

v={3,4,4}

gauss[m,v]