🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.borland
Article #329

Re: fibonacci programme

#329
From: Robert AH Prins
Date: Mon, 19 Apr 1999 00:00
30 lines
1896 bytes
In article <371B0391.E3122AD7@central.ntua.gr>,
  elhadzil@central.ntua.gr wrote:
> do you know how can I create non-recursive programme in pascal that will
> be able to estimate every term of the Fibonacci sequence?

There is a closed form available to give the mathematical exact value, the one
below! It's based on the fact that

lim fib(n+1)/fib(n) = (sqrt(5) + 1) / 2 (aka the golden ratio)
n->oo

r5     = sqrt(5)
fib(n) = (((1 + r5) ** n - ((1 - r5)) ** n)) / 2 ** n / r5

A quick test in Rexx (which, through it's "numeric digits n" feature, offers
precision only limited to the amount of storage you throw at it) showed that
the above formula is correct, well at least up to n = 1000. FYI, fib(1000) =

434665576869374564356885276750406258025646605173717804024817
290895365554179490518904038798400792551692959225930803226347
752096896232398733224711616429964409065331879382989696499285
16003704476137795166849228875

Robert
--
Robert AH Prins
prinsra@williscorroon.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Technical Details
Message-ID: <7ffeoa$avs$1@nnrp1.dejanews.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <371B0391.E3122AD7@central.ntua.gr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 108ebd,b2211ec9fb6b496,start
X-Google-Attributes: gid108ebd,public
X-Google-Thread: 111659,97274d7edc98e09c
X-Google-Attributes: gid111659,public
From: Robert AH Prins <prinsra@williscorroon.com>
Subject: Re: fibonacci programme
Date: 1999/04/19
Message-ID: <7ffeoa$avs$1@nnrp1.dejanews.com>
X-Deja-AN: 468295415
References: <371B0391.E3122AD7@central.ntua.gr>
X-Http-Proxy: 1.0 x11.dejanews.com:80 (Squid/1.1.22) for client 193.130.234.1
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Mon Apr 19 14:31:38 1999 GMT
Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal
X-Http-User-Agent: Mozilla/4.05 [en] (WinNT; I)