Off[General::spell1];
Clear[Cholesky,a0];
Cholesky[a0_] :=
  Module[{a, i,j,k,p,n},
  a = a0;
  n = Length[a];
  Module[{i,j},
   x = Table[0,{n},{n}];
  Clear[i,j,k,p];
   For[k=1,k<=n,k++, 
    x[[k,k]]=( a[[k,k]]- 
    Sum[(x[[k,i]])^2,{i,1,k-1}])^(0.5);
     For[p=k+1,p<=n,p++,
      x[[p,k]]=(a[[p,k]]-
        Sum[x[[p,j]]* x[[k,j]],
          {j,1,k-1}]) / x[[k,k]] ];]; ];  
  Return[x]; ];

A={{2,1,1},{1,4,1},{1,1,2}};
MatrixForm[A]

L=Cholesky[A];
MatrixForm[L]

MatrixForm[L . Transpose[L] ]