Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created April 10, 2017 02:56
Show Gist options
  • Save komasaru/04d1d4dfe7ea5d0d2dc0a3d587fe59e2 to your computer and use it in GitHub Desktop.
Save komasaru/04d1d4dfe7ea5d0d2dc0a3d587fe59e2 to your computer and use it in GitHub Desktop.
Fortran code to calculate series.
!****************************************************
! 級数計算
! : SUM((1/i) * (2/(i+1)) * (3/(i+2))) を計算する
!
! date name version
! 2017.04.10 mk-mode.com 1.00 新規作成
!
! Copyright(C) 2017 mk-mode.com All Rights Reserved.
!****************************************************
!
program series
implicit none
integer, parameter :: terms = 1000
real, dimension(terms) :: x, y, z
integer :: i
do i = 1 , terms
x(i) = 1.0 / i
y(i) = 2.0 / (i + 1)
z(i) = 3.0 / (i + 2)
end do
print *, 'ANSWER = ', sum(x * y * z)
end program series
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment