Last active
November 17, 2018 02:26
-
-
Save komasaru/086e3c1db6a747e99cae12b6269af3fd to your computer and use it in GitHub Desktop.
Fortran 95 source code to compute Napier's constant with FMLIB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!**************************************************** | |
! ネイピア数(自然対数の底 e)の計算 | |
! | |
! date name version | |
! 2018.11.17 mk-mode.com 1.00 新規作成 | |
! | |
! Copyright(C) 2018 mk-mode.com All Rights Reserved. | |
!**************************************************** | |
! | |
program napier | |
use FMZM | |
implicit none | |
integer, parameter :: KETA = 1000 ! 小数点以下の桁数 | |
integer, parameter :: N = 451 ! 計算項数 | |
type(IM) :: k ! 階乗部分 | |
type(FM) :: np ! ネイビア数 | |
character(16) :: fmt_s ! 結果出力フォーマット | |
character(KETA + 2) :: s ! 結果文字列 | |
integer :: i ! ループインデックス | |
call FM_SET(KETA + 2) | |
k = TO_IM('1') | |
np = TO_FM('1') | |
do i = 1, N | |
k = k * i | |
np = np + 1.0d0 / k | |
end do | |
!call FMPRINT(np) ! <= FMLIB 標準の書式で出力 | |
write (fmt_s, '("F", I0, ".", I0)') KETA + 2, KETA | |
call FM_FORM(fmt_s, np, s) | |
print '(A)', s | |
stop | |
end program napier |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment