I have a program that calculates the Fibonacci numbers from 1 to 100. The program runs fine. I am not sure how to take my output and display them in an ARRAY. Any ideas?(adsbygoogle = window.adsbygoogle || []).push({});

I tired to pass the array variable through the equation, but my output was weird. I would have 1, 1, 3347...... Basically, I would get the first two values, and then once the program entered my do loop, I would get very high integer values . I tried to use a DO loop at the end of the program, but I was unsuccessful.

EXAMPLE:

Fibonacci(i) = Fibonacci(i-1) + Fibonacci(i-2)

Code (Fortran):

Program large_integers

IMPLICIT NONE

Integer , PARAMETER :: M = 100

Integer, DIMENSION (M) ::FIBONACCI

integer, parameter :: IK = selected_real_kind(25)

Integer (IK) :: fn, f2, f1

INTEGER :: n, I

!allocate (FIBONACCI(fn))

! OPEN(14, FILE = "MY_FIBONACCI.out", ACTION = "WRITE", STATUS = "unknown")

f1 = 1

f2 = 1

IF (m >= 1) THEN

PRINT *, f2

END IF

IF (m >= 2) THEN

PRINT *, f1

END IF

DO n=4,m

fn = f1 + f2

PRINT *, fn

f2 = f1

f1 = fn

END DO

!DO i = 1, m

!write (14,*) FIBONACCI(fn)

!END do

CLOSE(14)

END Program large_integers

[ / code ]

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fortran 90: Display values in an array

Loading...

Similar Threads - Fortran Display values | Date |
---|---|

How to buy Fortran Programming Software Commersial License | Jan 30, 2018 |

Fortran for Computational Fluid Dynamics Problems | Jan 11, 2018 |

Porting Python Code to Fortran for Parallel Computing | Dec 15, 2017 |

Reading and Displaying text file in Fortran | Jan 7, 2012 |

**Physics Forums - The Fusion of Science and Community**