PROGRAM piformula
  IMPLICIT NONE
  
  ! Sto athroisma tha krathsw 5 prwtoys oroys => max n = 4. 
  INTEGER, parameter :: maxn = 4
    
 ! Tha xreiastw ta paragontika mexri kai to 2*maxn, mazi me to 0!, 
 ! xreiazomai 2*maxn+1 paragontika. Tha ta apothikeysw se pinaka:
  DOUBLE PRECISION :: parag(0:2*maxn)
  DOUBLE PRECISION :: s
  INTEGER :: i, n
  
  parag(0) = 1
  DO i = 1, 2*maxn
     parag(i) = parag(i-1) * i
  ENDDO
  
  s = 0.0d0
  DO n = 0, maxn
     s = s + parag(2*n)**3 * (42d0 * n + 5.0d0) / parag(n)**6 / 16d0**(3*n+1)
  ENDDO
  
  PRINT *, "to pi einai", 1.0d0 / s

END PROGRAM piformula
