Created
October 21, 2014 06:48
-
-
Save aptavout/f2303b6a44f9e38167fe to your computer and use it in GitHub Desktop.
Calculate natural logarithm
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
c | |
c evaluate the natural logarithm e | |
c | |
c variables | |
c 123456 a | |
c fln the value of the natural logarithm | |
c iterm the current term in the summation | |
c next the next number in a factorial operation | |
c fdenom the value of the current factorial | |
c | |
c234567 | |
fln = 1 | |
iterm = 1 | |
10 if (iterm .lt. 15) goto 20 | |
goto 30 | |
20 next = iterm - 1 | |
fdenom = iterm | |
50 if (next .le. 1) goto 40 | |
fdenom = fdenom * next * 1. | |
next = next - 1 | |
goto 50 | |
40 fln = fln + (1. / fdenom) | |
write (6, 70) iterm, fdenom, fln | |
70 format ('TERM: ', I2, ' DENOM: ', F15.0, ' ln so far: ', F20.8) | |
iterm = iterm + 1 | |
goto 10 | |
30 write (6, 60) fln | |
60 format ('THE VALUE OF THE NATURAL LOGARITHM (LN) IS ', F20.8) | |
stop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment