Skip to content

Instantly share code, notes, and snippets.

@zbskii
Created February 28, 2011 23:32
Show Gist options
  • Save zbskii/848277 to your computer and use it in GitHub Desktop.
Save zbskii/848277 to your computer and use it in GitHub Desktop.
C FILE: FIB1.F
PROGRAM FIB1
INTEGER X
X = 12
WRITE(*,*), FIB(X)
END PROGRAM FIB1
FUNCTION FIB(N)
C
C CALCULATE THE NTH FIBONACCI NUMBER
C
REAL N2, N1, FIB
N1 = 1.0D0
N2 = 1.0D0
DO I=3,N
FIB = N1 + N2
N2 = N1
N1 = FIB
ENDDO
RETURN
END
C END FILE FIB1.F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment