From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,55603c56db8d8307 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-20 16:32:07 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!ajpo.sei.cmu.edu!brashear From: brashear@ajpo.sei.cmu.edu (Philip Brashear) Subject: Re: Fibonacci Numbers? Message-ID: <1994Sep19.224716.24513@sei.cmu.edu> Sender: netnews@sei.cmu.edu (Netnews) Organization: None References: <35fl28$1h3@garuda.csulb.edu> <35gii7$3ef@crl.crl.com> Date: Mon, 19 Sep 1994 22:47:16 EDT Date: 1994-09-19T22:47:16-04:00 List-Id: In article <35gii7$3ef@crl.crl.com> weiqigao@crl.com (Weiqi Gao) writes: >In article <35fl28$1h3@garuda.csulb.edu>, S. Hegede wrote: >> >>Hey! I'm an a beginning Ada programmer and I've been stuck for a while >>on trying to write a program in which a user can get the number in a >>Fibonacci series( Ex. 1,1,2,3,5,8,13,21...) by typing its position in >>the series. I only need help on getting the formula down that would >>calculate the next number in the series. Thanks for the help. >>. >> >> > > >fib(n) = 1/sqrt(5) * [ ( 1 + sqrt(5))^n - ( 1 - sqrt(5))^n ] / 2^n. > >\/\/eiqi Gao >weiqigao@crl.com I'd be willing to bet that the assignment's intent was that the program use the "standard" recursive definition of Fib: Fib (1) = 1 Fib (2) = 1 For N > 2, Fib (N) = Fib (N-1) + Fib (N-2) At least that's where I always used the Fibonacci sequence: in showing a non-trivial recursively defined function. Phil Brashear