English
Source / code snippets

Fibonacci-numbers and its Applications

 

p.specht

Leonardo Fibonacci described in the year 1202 the growth of/ one Kaninchenpopulation and found moreover The today to it benannte Zahlenfolge the Fibonacci-numbers. Geschichtswissenschaftler pointed though on The early Erwähnung this follow in Sanskrit-Texten circa ca. 450 to Chr. there.

then watts discover, that these follow in the whole nature vorkommt: The Number of ancestors männlicher Honigbienen (Drohnen), The number the shed into individual Schuppenringen of/ one pineapples, The Samenlamellen the Spiralringe of Fichtenzapfen, Samenstände of Sonnenblumen or The Blütenblatt-amount bestimmter flowers (about Astern) follows this row.

Later advanced Mathematiker The Fibonacci-row on whom negativen Zahlenbereich, what u.a. to that Zeckendorf-Theorem led. this besagt, that each arbitrary whole number from follow not-benachbarter negative-indexierter Fibonacci-numbers zusammengesetzt go can. One from it abgeleiteter Binärstellencode can z.B. no next to each other auftretenden 1-values display, what with designed Applications a reliable Fehlererkennung allows.
further Applications ergaben itself with the organization of Databases in shape the undertow. Fibonacci-Trees. These are nowadys though sooner of theoretischem worth (Laufzeitanalyse).

Window Title upper$(\
"  Allg. Fibonacci-numbers:  Gültigkeitsbereich verschiedener Formeln (ua.: Moivre-Binet) testen")
'(CL) CopyLeft 2015-08 in XProfan11.2a by P.woodpecker, Wien (Austria), OHNE JEDWEDE GEWÄHR!
'Info-Base: https://de.wikipedia.org/wiki/Fibonacci-follow
Window 0,0-%maxx,%maxy-50:font 2:Set("decimals",0):declare n&,vz&,sg!
AppendMenubar 100,"N "+"_______ tab.1 "+"___________________________ tab.2 "+\
"__________________________________ Fib(%g) "+"____________________________ Fib(#) "+\
"_____________________ fibz_MoivreBinet() "+"_____________ Error "+\
"________________________________ n "
var f$="00,0,01,1,02,1,03,2,04,3,05,5,06,8,07,13,08,21,09,34,10,55,11,89,12,144,13,233,"+\
"14,377,15,610,16,987,17,1597,18,2584,19,4181,20,6765,21,10946,22,17711,23,28657,"+\
"24,46368,25,75025,26,121393,27,196418,28,317811,29,514229,30,832040,31,1346269,"+\
"32,2178309,33,3524578,34,5702887,35,9227465,36,14930352,37,24157817,38,39088169,"+\
"39,63245986,40,102334155,41,165580141,42,267914296,43,433494437,44,701408733,"+\
"45,1134903170,46,1836311903,47,2971215073,48,4807526976,49,7778742049,50,12586269025"
var fi$="0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,"+\
"28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,"+\
"14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,"+\
"1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,"+\
"53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,"+\
"1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,"+\
"27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,"+\
"498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,"+\
"5527939700884757,8944394323791464"

whileloop -80,80

    n&=&Loop:sg!=1:vz&=(n&>0)-(n&<0):case vz&=-1:vz&=if(int(0.5*n&)=(0.5*n&),-1,1)
    print if(n&<0,""," ");if(abs(n&)<1000," ","");if(abs(n&)<100," ","");if(abs(n&)<10," ","");n&,
    print tab(10);if(vz&<0,""," ");stature$("%g",vz&*val(substr$(f$,abs(n&)*2+2,","))),
    print tab(32);stature$("%g",fib(n&)),
    print tab(54);stature$(" ################0;-################0; 0",vz&*val(substr$(fi$,abs(n&)+1,","))),
    print tab(76);stature$(" ################0;-################0; 0",fib(n&)),
    print tab(98);stature$(" ################0;-################0; 0",fibz_MoivreBinet(n&)),
    font 0
    print tab(120);stature$("+################0;-################0; 0",fibz_MoivreBinet(n&)-vz&*val(substr$(fi$,abs(n&)+1,","))),
    font 2
    print tab(142);if(n&<0,""," ");if(abs(n&)<1000," ","");if(abs(n&)<100," ","");if(abs(n&)<10," ","");n&

    if %csrlin>49:print "   [Button]";:waitinput:cls:endif

    endwhile

    waitinput
    END

    Proc fib :parameters n&:declare i&,vz!,sg!,f0!,f1!,f2!

        sg!=1:vz!=(n&>0)-(n&<0):n&=abs(n&):f0!=1
        case vz&=-1:sg!=if(int(0.5*n&)=(0.5*n&),-1,1)

        while i&<n&:f2!=f1!+f0!:f0!=f1!:f1!=f2!:inc i&:endwhile

            return sg!*f2!

        endproc

        Proc fibz_MoivreBinet :parameters n&:case n&=0:return 0

            var vz!=(n&>0)-(n&<0):n&=abs(n&)
            var sg!=1:case vz&=-1:sg!=if(int(0.5*n&)=(0.5*n&),-1,1)
            var phi!=(1+sqrt(5))/2:var chi!=phi!-1
            return sg!*(phi!^n& + chi!^n&)/sqrt(5)

        endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/19/21  
 




p.specht

Fibonacci time differently
================
Since there it a verblüffende Formel from lauter irrationalen numbers (u.a. Goldener incision and his reciprocal value), with the one The ganzzahligen Results the Fibonacci-follow (0,1,1,2,3,5,8,13,...) herausbekommt, without jedesmal with 0 to begin. In times moderner computer game it naturally little strain, whom apparatus The items the follow To z.B. 1470 aufaddieren To lasssen. around the Genauigkeitsgrenzen the XProfan-Arithmetikpaketes auszutesten, is the Formel but straight correctly.!
Window Title " n. Fibonacci-number by Moivre-Binet-Näherung to charge (N=0..1474)"
'https://de.wikipedia.org/wiki/Fibonacci-follow#n%C3%A4herungsformel_f%C3%BCr_gro%C3%9Fe_Zahlen
Window Style 24:CLS:Font 2
declare n!

proc fib$ :parameters n!

    case n!<0:return "0"
    case n!>1474:return " ... > 5e+307 *** OVERFLOW ERROR *** "
    return stature$("######################0",(0.5+0.5*Sqrt(5))^n!/Sqrt(5))
    'works only, because stature$ rundet, means 0.5 dazuaddiert!

endproc

luuup:
locate 4,1
print "\n The wievielte Fibonacci-number to charge? n = ";:input n!
CLS
print "\n The ";int(n!);".te",tab(14);"Fibonacci-number ist",fib$(n!)
print "  Check through Aufaddieren with vorangehender number:",fibadd$(n!)
Goto "luuup"

proc fibadd$ :parameters n!

    declare fib!,last!,sum!
    last!=1

    Whileloop n!

        sum!=fib!+last!
        fib!=last!
        last!=sum!

    Endwhile

    return stature$("######################0",fib!)

endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/30/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.756 Views

Untitledvor 0 min.
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
Manfred Barei11/19/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (2x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie