Skip to content

Instantly share code, notes, and snippets.

@aptavout aptavout/natlog.for
Created Oct 21, 2014

Embed
What would you like to do?
Calculate natural logarithm
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
You can’t perform that action at this time.