×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Fortran Help ASAP!!!

Fortran Help ASAP!!!

Fortran Help ASAP!!!

(OP)
Hello all,

I am working on a Fortran90 code that will give me an approximation of a few mathematical constants. My code will compile and run, however, my outputs are given as 0.000000 for all constants that I am calculating in the loops. Any help would be greatly appreciated. My code is as follows:

PROGRAM HomeWorkOne_ProbOne

IMPLICIT NONE

! Computes an estimation of the exponential function, pi, and the Euler Constant

REAL :: e, EC, pi, n_factorial, x_factorial, gamma
INTEGER :: i, n, x


x = n + 3.0/2.0

n_factorial = 1.0


DO WHILE (n < 10)
DO i = 1, n
n_factorial = n_factorial * i
END DO
e = 1/n_factorial
END DO

DO WHILE (n < 10)
EC = (1.0/n) - (LOG(REAL(n)+1.0)-LOG(REAL(n)))
END DO

DO WHILE (x < 10)
DO i = 1, x
x_factorial = x * i
gamma = (2.0 * x_factorial)/(2.0 * n + 3.0)
END DO
DO i = 1, n
n_factorial = n_factorial * i
END DO
pi = (n_factorial)/((2**(n-(1.0/4.0)*Cos(3.14*(2.0*n+1.0))))+(3.0/4.0)*(3.14**((1.0/4.0)*Cos(3.14*(2*n+1))-(1.0/4.0)))*gamma)
END DO

PRINT *, "Approximate values of:"
PRINT *, "e =", e
PRINT *, "gamma =", EC
PRINT *, "Pi =", pi
PRINT *, "Actual values of :"
PRINT *, "e =", 2.71828182
PRINT *, "gamma =", 0.57721566
PRINT *, "Pi =", 3.14159265

END PROGRAM HomeWorkOne_ProbOne


Thanks for any help!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close