subroutine H_Inverse_Exact(n, Hinv)
! Inversa exacta a matricii Hilbert de ordinul "n"

real :: Hinv(n,n)
character*20 fname, charn*2
real numer

Hinv =0

ido: do i=1, n
fi_1 =fact(i-1)
fn_i =fact(n-i)
fni_1=fact(n+i-1)

jdo: do j=1, n
if(mod(i+j,2) ==0) then
dij =1
else
dij =-1
endif

fnj_1 =fact(n+j-1)
fj_1 =fact(j-1)
fn_j =fact(n-j)	

numer =dij*fni_1*fnj_1
denom =(i+j-1)*(fi_1*fj_1)*(fi_1*fj_1)*fn_i*fn_j

Hinv(i,j) = numer/denom 
enddo jdo
enddo ido

END subroutine H_Inverse_Exact
