Google Search

Saturday, October 24, 2015

FORTRAN Program of Fibonacci Numbers

c Fobonacci sequence
integer f1,f2,f3
f1=1
f2=1
write(*,*)'To display fibonacci numbers.'
write(*,*)'Enter the number of terms to be displayed:'
read(*,*)n
write(*,*)'The fibonacci sequence is : '
IF(n.EQ.1)THEN
write(*,10)f1
10 format(1x,I6)
ELSE
write(*,10)f1
write(*,10)f2
DO 20 i=3,n
f3=f1+f2
write(*,10)f3
f1=f2
f2=f3
20 continue
ENDIF
STOP
END

No comments:

Post a Comment