PROGRAM pi_calc_01b

IMPLICIT NONE

! Déclarations
INTEGER :: i, n_termes = 100000
DOUBLE PRECISION :: pi = 1D0, delta, pm_un = -1D0

! Calculs

helice: DO i = 2, n_termes
  delta = 1D0/(2D0*DBLE(i)-1D0)
  pi = pi + pm_un*delta
  pm_un = -pm_un
  ! IF(delta<1D-4) EXIT helice  ! Abandon prémature permis
END DO helice

pi = pi*4.D0

WRITE(*,*) 'Après la dernière itération:'
WRITE(*,*) 'i, delta, pi'
WRITE(*,*) i, delta, pi

END PROGRAM pi_calc_01b
