case j of
0:g[i,j]:=(g[i-1,0]+g[i-1,1])/6;
1:g[i,j]:=g[i-1,0]*5/6+g[i-1,1]/6+g[i-1,2]/3;
2:g[i,j]:=g[i-1,1]*2/3+g[i-1,2]/6+g[i-1,3]/2;
3:g[i,j]:=g[i-1,2]/2+g[i-1,3]/6+g[i-1,4]*2/3;
4:g[i,j]:=g[i-1,3]/3+g[i-1,4]/6+g[i-1,5]*5/6;
5:g[i,j]:=(g[i-1,4]+g[i-1,5])/6;
end;