LU Decomposition

LU[A_]:=
(U=A;
n=Length[A];
L=Table[0,{n},{n}];
For[i=1,i≤n,i++,
L[[i,i]]=1
];
For[i=1, i≤n, i++,
For[j=i+1,j≤n,j++,
l=((U[[j,i]])/(U[[i,i]]));
L[[j,i]]=l;
U[[j,i]]=0;
For[k=i+1,k≤n,k++,
U[[j,k]]=U[[j,k]]-l*U[[i,k]];
]
]
];
{L,U}
)

A={{1,1,1},{1,2,2},{1,2,3}};
LU[A][[1]]//MatrixForm
LU[A][[2]]//MatrixForm