subroutine SumSer(eps, res)
real eps
real(8) res
real(8) :: sgn = -1, z = 1, a
integer :: i = 1
res = 0
do
z = z * (2 * i) * ( 2 * i - 1)
a = sgn / z
if (abs(a) <= eps) then
exit
endif
res = res + a
sgn = -sgn
i = i + 1
enddo
end subroutine SumSer
program MainProg
real :: eps = 0.00001
real(8) y
call SumSer(eps, y)
write(*,'(1X,F9.6)') y
end program MainProg
subroutine SumSer(eps, res)
real eps
real(8) res
real(8) :: sgn = -1, z = 1, a
integer :: i = 1
res = 0
do
z = z * (2 * i) * ( 2 * i - 1)
a = sgn / z
if (abs(a) <= eps) then
exit
endif
res = res + a
sgn = -sgn
i = i + 1
enddo
end subroutine SumSer
program MainProg
real :: eps = 0.00001
real(8) y
call SumSer(eps, y)
write(*,'(1X,F9.6)') y
end program MainProg