n=input("n  =");
M=zeros(n,n);
i=1;j=1;k=1;
M(1,1)=k;
while k<n^2
    k = k+1;
    if i<n then i=i+1; 
        else i=i+1-n; 
    end;
    if j<n-1 then j=j+2;
     else j=j+2-n;
    end;
    if M(i,j)~= 0 then if i>1 then i = i-1;else i = n;end;
                       if j-3>0 then j = j-3;else j = j-3+n;end;
    end;
    M(i,j)=k;
end;
afficher(M)