integer function loca(i,j)
! Locul lui A(i,j); j=i,n - Triunghul superior - pe coloane - in a(n*(n+1)/2):

loca =j*(j-1)/2 +i
end function loca

subroutine iloc(n, k, i, j)
! A(i,j) stocat in a(k); k =1, n*(n+1)/2.
! Inversa lui 'loca':
!common n

! Determina loca(i,j) =k:
i_do: do i =1,n

	j_do: do j =i,n
	if(k <j*(j-1)/2) cycle j_do
	if(loca(i,j) ==k) exit i_do
	enddo j_do
enddo i_do

end subroutine iloc


