Daniel
2009-09-30 15:49:36
This is the Ultimate Fibonacci Number Generator :D It isn't only limited to the range of Int64's, but the range of an AnsiString, which can support over 2 billion characters! Or the range of an Int64 (which really depends on how many loops you want it to do).
Here's the highest number i went up to:
Enjoy guys :D
Here's the highest number i went up to:
From: Dan's The Man's Ultimate Fibonacci Number Generator
528380083589765432677493202316547207879421328870346896183434079043203799363737962347224802935034512710491126701654599379487882398944895951412901374096972891442267455898054879964586616903897771290095856541593813515554300075367030485904015852002279142755573064313348134330714716433085897157497810808547710510095405008561235866309236746637939814826308653532415410564251021544054930205428258801281786853279358532634142364252923169066887303936266186635348275992526146720626159762592569253483921979853337443299643649735112428653279809904446055597017139649588809234657725222787384665534961187916378328995866800203269637006902816415937351187403400254766616341448313730531634177910614556222413324250492499340058880242178528693028445767674184444932119333297180161900074038372687211226178709580193043354363609147626383358617285530432189730539913111823295698247680995994180077318284251788645984991879886646535175610236447407702207387401024717877012912949332619147465014582973983460114755386169607033522605940521611124112682222324125753600768508086260261523181052733355095039337247462217555506532259485869834266628017153234403107138554025638741016157075805622766631586016786095107087991991193588180276654453382923372609213720386939741904186883989232286914516682411451231652128320940407561388358199220485197514281954339286290296458526939555627542402168167577528939011941191007572861932095768354501609482964924984589738983857995009922581222413495658924470041137181447260306170241551381142463278109864482872606149326572482167771231344385571241158844347094374366387449214304613989123867939175195449143446207390595915344958661560784891533245620418017372066556152295577568494119078097262194623986175763389152196040071464892314031345960619009593658172467151967750097350358160140205434857112503278222856531371082070911299964038300189439379438072254265568865256352076017592068198901402529706716676694023397904515771226862907898560940754460783158983543832736843777378751535454977953170139266792807288407098647139681373040232358344315943344641698261491883203370620911776452356397512239609366952412840463152667788328291244797537115349909171176604643247924095436882839844656448032104021393424809561540314223465069932187521758911627844430073480911908163536295857658176854352847301448574157002720137701032308660024306743533301820489430288608279617711471778326992237818888249430135009840017170433748923784889465165934989501215740394994914161965593470027269319670950322078829473398915079007485703573166024924436308964799196223251799289214596458219465223419055068734106923414940673536103594354800682649428175630028472501137939957599808973911324024521258561650756552328615486637011259815340759988166721654941880928899938937491512059900028314696670536628733634788307054057972524641706537239376727312582146508563493381414616671972402529591574379109091255325028017023632944862866802511919278155209424593020678912204190776562685079125386070721133572684391743584976896218631755881549401280795648378392629979238839651259259224935340744518334541231370068014639363113622124041824094973137802204697157874352596703300943185751500842153648249345426096348219615038374391960181959236266982287469490354026905932031730332713619302727928325444280168271878883616656791260609408209605948252094881571897252025623606820237990538021031372895387815178899987912103136836453597351808843392480476541163288359483332327418714787148659873325195612682749129733583484851790630257107649072733594742169562026807433288993338038788211721579598518767092906927630411313421506190728616368316158627518139509305434539466771125980625555753029100566764657723530922107082760955717672169713456650555036356232609315629427285235317006474092525576730384381093930031777538450607116166846705824118371002640419882121311030392179788944069226470347248582101043188028869600164106763743973645302118307536571601251003429401415394490974277359866563472611340548513394018088874114727937568908184006155470064386048827747943581556891462327999289357562339381833625800220824106468053818669444136513602932340698316190202358412461433734660887452675879420501731407286512260563846433673704699549880205363992158161342000316291209586328477431233843221940191015129984479560427037724595432096751244753879641461347709039987562462557958086143297120534881956580425886428260704122547248410671784487736287141938265029083664303131233261240127192369822709910757847460802721810852492549915809985790911436930172535021843890613586099508388278990022925449183231498752206226425419963504162567758317861122946150720716294885150678194537346535257541891113285920315539473482768798537380664048940653530601134266372502547577539262579521364047359681710235186553556259147257529769791566363812759100036002439196696364594330680887038764506686222083195586609951246737782898919177935647881893020586525815257125420966447055196736928668967653937071446444223771732288383931593760643722531058880455355933205038943774230416005190100018272779974121206912772301584235101988473341656636143229346111369863450252108937037630717010297968467239751606570761219494642136095917094736192159767560152782333996131905028902906067240655314671236797879980297440253506981971378023053284533840663297588886955778258128772945950211648354477339397691956971862977295130783028470889538248286172269174508207182489419233580047401406522475817647802456343322673058308568930304057518139097739810400378781724496556501329245782946438731952078891681095750774959467272928779798177285510907540387095627482301031352305796161384806154341365812657659313922058086126440572551025160392513372570573086189997486053622075786113515556812208094266985055519199443187350651236708050947929304362283007495433925216719610422531130696897493171704434968774121806959308170012372276007881972093934804030127355074578448684192134811695738217222131253528984468553236939804331162495104657963241750390463859053999507302778467378538895642859938192861390510596436139521905705647522663519932347176611573252774185504010139282132614553421045387538923383066867428215393482033916055168686526982217523687640420603846044763266001510707145893889308584634829051659036214969788983802948889022002863462380453047455889107612548442908729523829207782349846734788655643423007818053354165076276807363073609281077218769863950603933315732514899696384212276417558093399095899958301358707129535904372007401635306089822476039146359471268432570424211715405924644446638850214718569327295794428999325396932620014795154065406779767874037871315622510317958982649350612523528215448998044186240321965407215969783951363663927770275303853997060275802575070655488161311884778631464748529652273221590450201145659960037489539722544661403229778620199648508707065593063760615420461368073136871305076231058552183393620850806688402407523076889096254650796326730284181878196378072883485380351064188273895797846095089952356304518465860784603454222512402474692911952203385276460601555492781448993218135273256756730118329030159087373823729423173191425643085861035058696393296846234428977586974691392710296073154421606195343675816670566156181324180357614495836353265288243715069542273884687801912986783630801101474742613845345852285779456211973092196345100831609912263817484555957954714348510005750543477254434682201226466878447941283352040417428732379054124373766219462149401377822795493038789290414011946019965251056358677351448749466844272294105087968421919080112024642644435860636353940516975186574057207431267539108511933663399836915516113002140475225252598388688910074548047373948071433547903452850992462372899791561761406770539874970204208774822461853215782805394227844251170650213018370094708524355549889322015665385363076938141793707194700235374363142054119634514879895439053050977968685306673883756443999176658232967257368953624594197529150747252997718643585518749854035133753040088122636480494122444827631522992046153415828138598906847585184602828386029751773899810448071531822012596433245660554660285881705813603375603835099384821934790743129644353882410836809625030138821781915099285008161820593086848028324944918581644851882599700477875035909642508553038307031936472649689196558439363967909499906533558426546807595048900841454220534573027941803478828592163777753879747039834281557235351774099233742693890925685135721378468416394282535396718081261424025605954888275778721559283665
Enjoy guys :D
// -- Dan's The Man's ULTIMATE Fibonacci Number Generator!
const
Times = 10000000000; //How many times to do the Fibonacci?
WPeri = 2; //Wait period between Fibonacci prints?
PrAll = True; //Print all the Fibonacci numbers?
function Plus2Str(Str1, Str2: AnsiString): AnsiString;
var
i, bI, Remainder, cI: Integer;
bStr1, bStr2: AnsiString;
begin
bI := Max(Length(Str1), Length(Str2)) + 1;
bStr1 := PadZ(Str1, bI);
bStr2 := PadZ(Str2, bI);
//bI := Length(bStr1);
SetLength(Result, bI);
for i := bI downto 1 do
begin
cI := StrToInt(bStr1[i]) + StrToInt(bStr2[i]) + Remainder;
if(cI > 9) then
begin
Remainder := 1;
cI := cI - 10;
end else
Remainder := 0;
Result[i] := IntToStr(cI)[1];
end;
if(Result[1] = '0') then
Delete(Result, 1, 1);
end;
var
D, A, Tmp: AnsiString;
I: Int64;
begin
ClearDebug; //Comment out to not clear the debug box =P
D := '0';
A := '1';
for i := 1 to Times do
begin
Tmp := D;
D := Plus2Str(Tmp, A);
A := Tmp;
if(PrAll) then
begin
Writeln(D);
Sleep(WPeri);
end;
end;
if(not(PrAll)) then
Writeln(D);
end.