C Problem 5 on page 244 of Nyhoff and Leestma. C C Print the first N numbers of the Fibonacci sequence where N is C specified by the user. C C John Schneider C CptS 203, HW 4, problem 1 C-------------------------------------------------------------------------- program fbncci implicit none C..... C Let f_i be the ith number in the Fibonacci sequence. C old = f_(i-1) C new = f_i C temp = holds f_i when resetting new to f_i + f_(i-1) C i = dummy loop variable C n = desired number of terms in sequence C..... integer old, new, temp, i, n C.....Initialize old and new to the first two terms in sequence. old = 1 new = 1 print *,'Enter desired number of terms in Fibonacci sequence.' read *,n C.....Handle first two numbers in squence as exceptions. if (n .ge. 1) then print *, old endif if (n .ge. 2) then print *, new endif C.....Terms 3 through n. do 10 i=3,n print *, old+new temp = new new = new + old old = temp 10 continue stop end