Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Layered object

80 views
Skip to first unread message

jonas.t...@gmail.com

unread,
May 21, 2016, 1:41:36 PM5/21/16
to
I have an object storing integers, many formulas may of course generate the same integer. And for some expressions for example on form a*x^j i would like to store each occurence. Now all my numbers are printed out in a square grid.

Right now the storing structure look like this and i set fontcolor and rectangle color as i print out the grid.

However i would like to store multiple func and rcolors within same object?
Thus make func and rcolor the multidimensional part of the array.

I am totally clueless for how both initiate and update such an object in javascript. I have managed to do it for numbers but i never initiated the object it was somehow forked in as i updated the object. And i really did not understand how it really worked. So if someone could show me howto make this array of integers to holld multiple functions and rectangles for each arr[i] it would be great.

function arraysize()
{

for ( i = - scope; i <= scope; i ++ )
{
arr[i] =
{
count : i,
func : '',
fcolor : 'black',
rheight : 100,
rwidth : 100,
rcolor : 'white',
prime : true,
formula : 0,
sigma : 0,
}
}
}

Aleksandro

unread,
May 21, 2016, 7:41:58 PM5/21/16
to
Sorry but I am drunk lol I wall think for an ann-er in the morning lololol

jonas.t...@gmail.com

unread,
May 22, 2016, 2:42:41 AM5/22/16
to
Lets hope you sobered up...
var x = new Array(10);
for (var i = 0; i < 10; i++) {
x[i] = new Array(20);
}
x[5][12] = 3.0;

How does this relate to my example array above?
I do not know how many occurences there will be, and it is only the func and rcolor property of the object that will be multidimensional.

for ( i = - scope; i <= scope; i ++ )
{

arr[i] =
{
count : i,
func : '',
fcolor : 'black',
rheight : 100,
rwidth : 100,
rcolor : 'white',
prime : true,
formula : 0,
sigma : 0,
}
arr[i] = new Array(20);//??????????
}
}

jonas.t...@gmail.com

unread,
May 22, 2016, 6:50:40 AM5/22/16
to
If i let out 20 above, arr[i] = new Array(); will the subarray dynamically assign memory as i pass new properties?

So to update the object i use arr[x][y].func="mystring" or arr[x][y].rcolor="green".

Is there space allocated for the rest of the attributes/properties of the object?

Does the object creation and the update seem right?



Michael Haufe (TNO)

unread,
May 22, 2016, 12:03:24 PM5/22/16
to
On Saturday, May 21, 2016 at 12:41:36 PM UTC-5, jonas.t...@gmail.com wrote:
> I have an object storing integers, many formulas may of course generate the same integer. And for some expressions for example on form a*x^j i would like to store each occurence. Now all my numbers are printed out in a square grid.

Don't. It's going to be slower.

jonas.t...@gmail.com

unread,
May 22, 2016, 5:59:50 PM5/22/16
to
Well just storing them within the array can hardly slow it down or?

Michael Haufe (TNO)

unread,
May 22, 2016, 6:57:57 PM5/22/16
to
Memoization isn't free and your approach would be even less so. I've written a little about this topic in the past:

<https://thenewobjective.com/blog/2013/01/dynamic-programming-for-great-justice/>

jonas.t...@gmail.com

unread,
May 23, 2016, 1:46:12 AM5/23/16
to
Beside for the last example, what is really the benefit of the recursive examples compared to the iterative?

For me that is not used to recursive calls the iterative naive approach using for and while is much easier to read and understand.

What is the main benefit with recursive calls, speed?

jonas.t...@gmail.com

unread,
May 23, 2016, 2:05:12 AM5/23/16
to
Do you have any suggestion, or do you just say it is not wise to make a deeper multidimensional storage structure?

I think the script could benefit from using a layered structure for the expression. For those integers that get multiple occurences i just put a border around no need to draw them out.

And then you could use an optional event handler on mouse over and on mouse click to zoom in and scroll through the occurences/expressions.

jonas.t...@gmail.com

unread,
May 23, 2016, 2:08:56 AM5/23/16
to
I like your writing style better than the recursive programming, very clear and concise. :)

jonas.t...@gmail.com

unread,
May 23, 2016, 11:31:41 AM5/23/16
to
For even greater justice, but a tad slower using base 10 but faster and bigger using bigger base.

<script language="Javascript">

/*ADD TWO VARIABLES USING CHOSEN BASE*/
function naiveAdd(base, arrOne, arrTwo)
{
addOne=arrOne.slice();
addTwo=arrTwo.slice();
abigArr = addOne.length;
asmallArr = addTwo.length;
addResult = [];
remainder = 0;
for (i = 0; i < asmallArr; i ++ )
{

addOne[i] = addOne[i] + addTwo[i] + remainder;
if (addOne[i] >= base)
{

addOne[i] = addOne[i] - base;
remainder = 1;

}
else
{
remainder = 0;
}
}
// If strings of equal length but there is a remainder;
while (remainder == 1 && addOne[i]==(base-1))
{
addOne[i] = 0;
i++;
}
if (remainder == 1) {if (isNaN(addOne[i])) addOne[i] = 0; addOne[i] = addOne[i]+1;}
return addOne;
}

/* COMPARE SIZE OF TWO ARRAYS, IF A < B RETURN TRUE, IF B >= A RETURN FALSE */
function lessThan(A, B)
{
var AA = A.length;
var BB = B.length;
if(AA > BB) return false;
if(AA < BB) return true;
// AA = BB, compare indexes from biggest to smallest.
for(i = AA - 1; i >= 0; i -- )
{
if(A[i] < B[i]) return true;
if(A[i] > B[i]) return false;
}
return false;
}

/* ORDER THE ARRAYS SO THE BIGGER IS PASSED AS FIRST ARGUMENT*/
function orderArrayAdd(Abase, A, B)
{
return lessThan(A, B) ? counterArr = naiveAdd(Abase, B, A) : counterArr = naiveAdd(Abase, A, B);
}

/* GET VALUES FROM INPUT*/
function fetchValues(){
base=document.eval.FBASE.value;
myeval = document.eval.expression.value;
lucasStart = document.eval.start.value;
lStart=parseInt(lucasStart)
lucasScope = document.eval.scope.value;
lScope=parseInt(lucasScope)
}

/* PARSE VALUES FROM INPUT */
function parseToInt(){
if (result = myeval.indexOf("+") != - 1)
{
opArr = myeval.split("+");
operation = "+";
}
arrOne = opArr[0].split("").map(Number).reverse();
arrTwo = opArr[1].split("").map(Number).reverse();
}


function main(){
document.eval.result.value="";
document.eval.timing.value="";
evalStr="";
var out=[];counter=1;
fetchValues();
base=parseInt(base);
parseToInt();
flip=0;
/* TIMER START */
var start = new Date().getTime();
lEnd=lStart+lScope;

while(counter<=lEnd){
out=orderArrayAdd(base,arrOne,arrTwo);
arrOne=arrTwo.slice();
arrTwo=out.slice();
if (counter>=lStart && counter<lEnd) {fib=out.slice();evalStr+=counter+"th"+" "+fib.reverse().join(',')+"\n";}
counter++;
}
/* TIMER END */
var end = new Date().getTime();
var time = end - start;
document.eval.result.value+=evalStr;
document.eval.timing.value+=time;
} </script>

<html><body onLoad="main()";>
<H1>FIBONACCI AND OTHER SERIES</H1>
<form name="eval" onsubmit="main(); return false;">
CHOSE BASE <input type="text" name="FBASE" value="4503599627370495" size="20"><P>
<input type="submit" value="Generate"><input type="text" name="timing" value="" size="4"> ms<br>
Start print x'th number in Serie<input type="text" name="start" value="100000" size="9"> How many follwing in Serie -><input type="text" name="scope" value="1" size="9"><br>
Generate Serie expansons using startvalues<input type="text" name="expression" value="1+0" size="10"><br>
Result <textarea name="result" cols="100" rows="30"></textarea><br>


</form>
</body></html>

jonas.t...@gmail.com

unread,
May 24, 2016, 8:38:51 AM5/24/16
to
I am not sure what all the prescriptions is all about but i sure find them annoying.

Michael Haufe (TNO)

unread,
May 25, 2016, 8:13:46 PM5/25/16
to
On Monday, May 23, 2016 at 12:46:12 AM UTC-5, jonas.t...@gmail.com wrote:
> Den måndag 23 maj 2016 kl. 00:57:57 UTC+2 skrev Michael Haufe (TNO):
> > On Sunday, May 22, 2016 at 4:59:50 PM UTC-5, jonas.t...@gmail.com wrote:
> > > Den söndag 22 maj 2016 kl. 18:03:24 UTC+2 skrev Michael Haufe (TNO):
> > > > On Saturday, May 21, 2016 at 12:41:36 PM UTC-5, jonas.t...@gmail.com wrote:
> > > > > I have an object storing integers, many formulas may of course generate the same integer. And for some expressions for example on form a*x^j i would like to store each occurence. Now all my numbers are printed out in a square grid.
> > > >
> > > > Don't. It's going to be slower.
> > >
> > > Well just storing them within the array can hardly slow it down or?
> >
> > Memoization isn't free and your approach would be even less so. I've written a little about this topic in the past:
> >
> > <https://thenewobjective.com/blog/2013/01/dynamic-programming-for-great-justice/>
>
> Beside for the last example, what is really the benefit of the recursive examples compared to the iterative?

From the standpoint of speed and memory? They're equivalent as I explained:

O(n)/O(1) time/space

From the standpoint of brevity, the recursive form is 3 times shorter. ES6 evolved since I wrote the original. Here is a more modern comparison:

//before
function fib(n){
if(n < 2)
return n;

var f0 = 0, f1 = 1, f;

for(var i = 1; i < n; i++){
f = f0 + f1;
f0 = f1;
f1 = f;
}
return f;
}

//after
var fib = n => {
let f = (n0,n1,step) => step == n ? n1 : f(n1, n0 + n1, step + 1)
return f(0,1,1)
}


> For me that is not used to recursive calls the iterative naive approach using for and while is much easier to read and understand.

Easy != Simple. Easy just means familiar. With practice you can understand recursion just as well

> What is the main benefit with recursive calls, speed?

The main benefit IMO is the ability to write concise algorithms that solve a problem in terms of itself.

Michael Haufe (TNO)

unread,
May 25, 2016, 8:15:20 PM5/25/16
to
On Monday, May 23, 2016 at 1:05:12 AM UTC-5, jonas.t...@gmail.com wrote:

> Do you have any suggestion, or do you just say it is not wise to make a deeper multidimensional storage structure?
>
> I think the script could benefit from using a layered structure for the expression. For those integers that get multiple occurences i just put a border around no need to draw them out.
>
> And then you could use an optional event handler on mouse over and on mouse click to zoom in and scroll through the occurences/expressions.

I think you are trying to solve too many things simultaneously. Start from the bottom up instead of the top down.

Michael Haufe (TNO)

unread,
May 25, 2016, 8:21:24 PM5/25/16
to
On Monday, May 23, 2016 at 10:31:41 AM UTC-5, jonas.t...@gmail.com wrote:
> For even greater justice, but a tad slower using base 10 but faster and bigger using bigger base.

Posting a large amount code that isn't even valid/formatted is more-so an injustice... I think I've said this before: at a minimum post legal code/markup if you want people to be less likely to ignore your questions.

Resources:
<https://validator.w3.org/#validate_by_input>
<http://jshint.com>

Michael Haufe (TNO)

unread,
May 25, 2016, 8:22:46 PM5/25/16
to
On Tuesday, May 24, 2016 at 7:38:51 AM UTC-5, jonas.t...@gmail.com wrote:
>
> I am not sure what all the prescriptions is all about but i sure find them annoying.

Prescription drugs? That would explain a bit...

jonas.t...@gmail.com

unread,
May 26, 2016, 1:57:04 AM5/26/16
to
The nonsense ads, i find them annoying. For some reason there usually comes a dozen or so as soon i post some code.

If there is no speed gain i think i keep the simpleton / naive approach. I think beginners in programming will favour understanding that code. When i look at recursive code it look so entangled.

The operations seems snared into the execution part, with c=a; a=b; b=c; there is really no doubt about what is happening wheter you use a for or a while loop.

Regarding my code, it may not be beautiful but it certainly does what it is meant to do in a miracuous way. Finding Fib nr 100000 and printing it in 5 seconds.

That is a 21033 digit number... so my approach to programming may not be so bad afterall...

And ***I*** did calculate and wrote it out using 2k of code in javascript, a feat you and the other simpletons of this group ;) would not dream of without the help from my code.

jonas.t...@gmail.com

unread,
May 26, 2016, 2:07:54 AM5/26/16
to
By the way Wolfram Alpha is way off, it seem it cannot handle numbers of that size without doing some dysfunctional approximations.

jonas.t...@gmail.com

unread,
May 26, 2016, 2:10:29 AM5/26/16
to
You see my bignumber approach actually work weither it is 20000, 200 0000 or 2 million digits.

I'm just a tad better.

And it works in anybase.
https://www.youtube.com/watch?v=5NJZre-2QBE

jonas.t...@gmail.com

unread,
May 26, 2016, 2:24:11 AM5/26/16
to
The 100 000 Fib
20552 characters in base 10,000000 ends with a 5

25974069347221724166155034021275915414880485386517696584724770703952534543511273686265556772836716744754637587223074432111638399473875091309656973821883044935228763853133492135326792789567015127657827163560807350532224323311438398651613782723812477745377833729991621463450054669860398627509966393664092118901252719601721050630035058689402855810367511765825136837743868493641345733883436515877542537191241050332195991330062204363035213756525421823998690848556374080179251761629391754963458558616300762819916081109836526352995440694284206571460449380564713634633000520852277707554446794723709039790191486043284681985796115951018506082649192345873133991513391993236312301864172536477136266475081339824312317343145296418179005118795731676683497990168201184990775668645684506628739248560391404760519955006628882634587718941068037009187936500173301171002831047394745625691444932821374855573864080579813028266640270354294412104919995803131876805899186513425175959911525631553377039969410355182752749199598022575079023779813089922984996304496255814045517000250299764322193462165366210841876745428298261398234478366581588408190330738293950082132093747154851312722081730543226486694963098791471436292555425262404399961532697987687510646819068792118299167964409178271868561702918102212679267413626549978496884368097525470013145741864064482994858725517447466956518791269169932445648176733222571493149677633458466238303338223970243685947828764187578857291071013370300094229333597292779191409212804915459762627915705524815888405177941819295216769576608748815567860128818354354292373978115478570132843861272862017665395344499300198006295389369855007232866513171811358866135374726845854325489811371766051946169379168844253425947812631388952479565943807153019112539648471126389007133628569101551453423329441284357220996286746119420951661023097470996553190058158669911445442647882872642845017253320486483194578920399848938236367456182203750973485668474338872490493370316338265717607297788917989136673251962324711803728017392157239082276922807729245666275053833750069260772159361942126892030256744356537800831830637593334523502569729065152853271943677560156660399164048825639676930792905029514886934137991251748566670747175149389790386533381395346848378086126737554383821108448976538368483182588363399173104558509056638462025014631311831087429077292622159430242915947403061018398168550669502619737615857176119947587572212987205312060791864983615969233959410411863516885488391191851790615115627529361584900087215019222651178531508925102752804515123860379218469212153382928713692432152733271415747882959026015719548531644479454675285840236000238344795203451080332820138038807089807348326201227952633606773669875783326254859449602191736886778624112056210983698519729017715781120404586491539351157834995461006366357454485082418882790675313599505192062229760153765297973085881648731173082370598284894044874039320535929359764541655607954724778620299692329561389719894679422187273605123365595211331087787582288795975803204596084790245063851941743126163775104599211248687949634170686209290889306852523480569259983337751039010131661781230511457193276629167125446512151746802548190358351688971707576778656188008220346836321018130262329960275994035799977740462449521145315883703579044832931500072461734173558055678321534543411700202585608916629419863740151456957227283692196322951118776253075340259478144820465746028848556280693481139827601685558407954216205754355729151064153759293902288435612079264375560062367986544382464373946972471945996555795505838034825597839682776084731530251788951718630722761103630509367426226171736305861329154424695432904616258691774630578507674937487992329181750163484068813465534370997589353607405172909412697657593295156818624747127636468836551757018353417274662607306510451195762866349922848678780591085118985653555434958761664016447588286336297040462890976773625658430235314749461233912068632146637087844699214275415694109122465685712047172411333784898167649692498163342117685715031167104006817530319211541561195804257065869312727621371069747222602965552461105371555453249975843275200199214301915053629960070429632978051036665063878626815765877268374512897685079636637105938091122542883583919412115477375998130192165095214013330607098731373292651816922684506344395405672981203154639232498179378046910379342216949522917930299492375072993250630594281390279308413447306141164335561476409310442591848136393054236937897652052645634764831827263337151211203062923388928648794920973784786188486826804647319539284039830800880386904955741975621929392211082576639768136104449002472948340326796768837621396744757138872928630798218493143438797780887379588968409461434159271317578365114578289355818599292353438888884658745213083813777944363611976283903689459576012031650227985790154534474735270697285145459986142290273729113146378204551622544753535677362279364854503571020864454120898423503890877223039849380214734809687433336225449150117411751570704561050895274000206380497967964026178186644812485472696308234733772455433905198413087697812765659167642290229481817630757102557933650081522863836344931380899717858707086363220586901893837776606300606675773242727292924742129526500076646722730009956124191409138984675224955790729398495608750456694217771551107346630456603944136235888443676215273928597722879373559667239246138274687032178584599482575147454064364609970593161205968415604732343966524572316503177928338605938836041769142873273570398680334264670071717363573091122981306903286137122597937096605775172964528263757434075792282180744352908669606854021718597891166333863858589736209114248432178645039479195424208191626088571069110433994801473013100869848866430721216762473119618190737820766582968280796079482259549036328266578006994856825353643667482253460375134503603152154296943991866236857638062351209884448741138600171173647632126299614856192559970756682786677873237741944446227539990929104469771647615111867232723867928133367306181944849396607123345271856520253643621964198782752978813068031314181706931446822118927578497828109436775154071016350553798003842219045508482239386993296926659221112742698133062300073465628498093636693049446801628553712633412620378491919498600097200836727876650786886306933418995225768314390832484886340318941941613697984383334660867670943164365353843091215781554351285207772085809892099586449602479491970687237656871092343807195098248144731578137800863935841875665509850132188285284018498140769073850736953537771188038852893534760093338598691608289335421147722936561972762646037262723932099118782040767412272258127667294007192423793330972132364184093956102995971291799828299539147382437802779051112309545825328887211461701334403859396540478061993332245473178034073409251213217279595753863158148810392952475410943885550983826276331276067181261710220113561818007754002275167341441692164249731756213631285882819780578883245453458152243493726813343399771051253208147834567139835038332901313945986481820272322043341930929011907832896569222878337497354301561722829115627329468814853281922107523736268276431526857354932230280181014496490091552924863833888566489300225097434360120081436515362536919944670971112695196672578061891215440222487564601554632812091945824653557432047644212650790655282083379760714651275832048716527157747232588727576112835759213255393444628943325815028633583669291828566894736223508250294964065798630809614341696830467595174355313224362664207197608459024263017473392225291248366316428006552870975051997504913985946807101360233644016441791886108532307649917143720544678235972117604651532001630853363193515896458906817223728123103202718979179512727996565369403211124284659099455638021546131610626752163380566439431888126819949400553706869762185523185892110096344101293353573391845966819753983428469682288946007635203168892200202193131836975755696206111577430582630553586201563789124631220672933992617378379625150999935403648731423288739779689089083699962929953919772177965334212492919783837514600620549673416628334873410110977705358980664981360113955715843283087139405825352740560810115039079416880791972129331483030726386786314110384431282159949368243429981887197686376044963425975242568861886889789808883158650762626048564650043228968561492550639688114044004295038942458723822335431010786915173283336047792627277656860761777056168740525774374998377583014385613542727383858977413352694916548392972151955479357892386676250274537010466090938244962662693532130374453889247921616118888970207791044856319951482663080287954954645358386630734442375331971227915886177289652090149848305435983207713266534072906620167757064096901837712013068232453334779666652532549087361961483782415660712716503835822572892157820936951099589013285949072430618332575521208097175220229497428018234454137119162984499147222541965946822214682606449618392542496709031040075814888579716722463228870164384039084638567311643081695373267903311458368057521119639905615169154708510459700542098571797318015564741406172334145847111268547929892443013914682891036791792169786165824897322033591376706527676521371439853027609884780562169946596554613791749856597392273794167264953778019929835542786617912312669937473077773569324430166839333011554515542656864937492128687491217542459678311329692484924667442619993397282567487346020115044222878046612432018301618232183908654771042398228531316559685688052265714744288233175394565438819286244326625033453881995900851521138312449186180262443219554043398572284134125440941177172215686708629174212405311062052284298619927362940620883475485364512812327960909721395377536002307676569420821994303464878334854449271353945022459133437466493770165560576338469706291872574542655879414630176639760457474311081556747091652708748125267159913793240527304613693961169892589808311906322510777928562071999459487700611801002296132345882945584409524966111583428049086438608807964455776369185774375402589685592725251456340438521782589059955395462745138545445291676104296926797089358005623450191857148903041849576740081935997321871195749635709596782517109626475206889080640765144589313287076745416960710793169270428516893413311046353506242209810363216771910420786162184213763938194625697286781413636389620123976910465418956806197323148414224550716172158513213020306841760872158927020988791089380810459033972765473264169168454456276007595613671035845756490944306924525328500309106878315756151984756756919128478465469255866511155791346127242533608363513134218395177154511228464455136016013513228948543271504768393075561009878609666387061227869027483181933160670148495716300470526222823840626681844878837454813199438038761383012885988526420199228618820849958864088852135250145761539648264745102590253074317295689963649961570755185583716593536712544851508936290456773663003556245737477910098799249914696722404148160128953094401548894261378314008780431143174185807182618514951138744831358439067228949482582860216502889272283874264327861686903819605315589445945188735197246008221529343980828254126128257157209359853828007385604729194118460844852353778335033068619777245018863647034497336647310060218128792886991861824418453968994777259482169137133647474531729798092458443611296189975956962409718455642051143258959184472492094293030165148871379802123790655365251547802980594075294405131458755153779486163587991158192019808879694967187448224156836463534326162426329347616344581638901638051238941845239734218414968892623984896486420934981668149477115517709562669029850101513537599801272501241971119871526593747484778935488777815192931171431167444773882941064615028751327709474504763922874890662989841540259358340351420351361688192482389980277666691634213342431205450735938861668769118818577611813577133248396520988208598239129860638682280475436248956522921410859852037330544625953261340234864689275060526893755148403298542869912210525970056285767077256769530097897004648920009852106980295419699802138053295798159478289934443245491565327845223840551240445208226435420656313310702947223715527705426348207398445488958924886139765779145414427653584572951329719091947694411910966797474262675590953832039169673494261360032263077428684105400613510521944137781580950571452684600981035219249042795850736436961021241137739717164869525493114805040126568351268829598413983222676377804500626572417317573952197968907548251993292596498162706866565830178877405615167159731927320479376247375505855052839662945669925221736008740812121420907104193759857172143133801742514158249182471090508471597724941704932025416523932323325885158889333797136310892571531417761978326033751090262840664158013713593565292780884563059517708144399411467429185036074885236665474486992808323051681571160291183637414795849210086052898146954775081233889694315286102120273674704990393417035171342126923486700566627506229058636911882228903170510305406882969708755453293694346398129769647803182545164217834734771647158423238594581830527562139101869976043058440686657123468696794560441557421039179758348979935882751881524675930878928159243492197545387668305684668420775409821781247533545231947973989533201759886402810588255576980439712538312459428957377696001857497335249965013509368925958021863811725906506436882127156815751217129765992750370228283963962915973251173418586721023497317765969454283625519371556009143680329311962842546628403142444370648432390374906410811300792848955767243481200090398884572709077508736388732996425555047381252897596293482287891761992725138309388288292514168376227582408191893360365387528411678570372098971883298692192781662967584458017491180911966304818743415506779086394883148924150430047674527971283482211522228370628573142441078237925136450866775666228049772113971406216641163247567842166129614771090188269467737768640617672148429389497667138012278894139026553511096118347012565197540807953840609168639369066737866272094294342642604029215831734500372746258899262204987712117845563348492490326003585690993823927772974984135656148307882623633223683807098223460122742413790364734517359252157547571609342709351929017239549214264906911152715233381912404281210289373848816735895393450893069771552298919969890388588327540904430032198683400347027122002015969937169065033054757709539874858067002449104550489006172718916803139452803616563394157133463722255047754746075605502410876438212168884891694037125890194849068537972224456200948381949153272450227621858916950745794983759821660448199651936011026157694717620257170248684914616894068404140833587562118319210838005632144562018941505945780025318747471911604840677997765414830622179069338538751292989830095827755414543505876898494417913653589162009872522249055183554603706533183176716110738009786625247488691476077664470147193074476302411660335671765564874440577990531996271632972910944924921645603061882777294775764777446452586328919159107444252320082918209518210837353881330983215894686801279542247520719241346483349639150948130975414332442092999307514810779192346128122331617994299306188005334145506339321393396468616164169552202164479954172431711657444713641977332048993650747678441499295480730258564429423817876415064928783617679786771585107842357026402133880188756019892340568684232155856285864552525837710620532224244987990625263484010774322488172558622333020763999338541520153438477254429178951306370503204449177977523787195827797679968611362653229111862963116468515993466069346055754595663155830033697634000276685151293843638886908283761411577320035275651587459065670254394379311048385713132944906492658236310894953509008267315449722639664808861804157397788847289217461897418972177700098624496537590127270152276345108749694801221068495206302519011655963580552429180205586904259685261047412834518466736938580027700252965356366721619883672428226933950325930390994583168665542234654857020875504617520521853721567282679903418135520629998953664701065579532129541336924472492212436324523428951884617791223386967423398069488727058750338922839509513520912319258159006960395156367736067109050566299635718764232479207528361608055976977787564767672152122232718482148444663126148758422609260887576433173102326376886482259469121103236773755812213347055680595800831012748167396201958359802396741448986727684586981937678375716793672321308158619104599505897099106468691946344803857414382962954713137217366983618455814455748676124322451519943362182916191468026091121793001864788050061351603144350761892134416024880917410512322903571792054979279709245024799408426961588184426161637800447594782122408732041244211691998055726491182436619218357147628914258057718717436880003241130087048193739622950171430900984769272374988759386399425305953316078916188108635598244457894279934651491595288486975748802582335357167786482682805114885429732788197765736966005727700162592404301688659946862983717270595809808730901821209313430058796552694788498092548430546761134654748067296743997636125924346377199958438628123919854702024148800768808188480878923915913694632931132768493297772016466417275872591223547844808134333280500877588552646861195769621722393086937957571658218524162043419723839899327348034292623472233815510229101262949249742423271698842023297303260161790575673111235465890298298313115123607667739689981538122869996420146098525797936912460163460887623212862056342159014791886321946596374834825642916162785329482393132294402310432772887681395502133482663886874532592815878545038909915619496324788550350902893997371898800399902613201587267863787309567810962531100805448941885798356590206368069964316533912029944327726770869305240718416592070961392864019667257508701221814973313369580960036975176495135040285926249203398111149532275336218445007443315624345324842179861083462613458975912348399707518542232816771872159568272432459108290198863936978454262256691254274705697567984857136623679238784781612014779829390805131502581745237735295101652969345627861222411507835877553733483727644398380826672147400344663227769189369676128789834889420946881023084273645285450496675969731883604449670285319063739691635798928865719935397723495486787180416414152814894437850362910715178052858575839877111454742401564164771941163913549354667555935926088492005463846854030280809364172505836533680934072253108208447235702268098269514261624512040407115014487478561999228146645658939384880286438223138498523284523606670458051136796637510392481633361732745472757756368109773445392758275605974251607546868965779453052162315939865780974801515414987097778787053570580084723768924221897503127585271401731176212798987449584061998439133656802977212875193498850449971391428515803232482302134063031258607262454163776523450552251086318285359658520708173392709566445011404055165790550374177803933516583690454347721422281816832539613634982525215232257690920254216409657452618066051777901592902884240599998882753691957540116954696152270401280857579766154722192925655963991820948894642657512288766330302133746367449217449351637147257329808328127264681877593565842183835947027920136639076897417389622525757826639908097926470114075803678505993818871845600946958332707751261812820153910417739509182441375619999378192403624695582359241714787277944844310875190187414112903707060520851629757983617542510416422448675773507563380188953792631833898559559565278572279261555244947393636655339452865621546428834316228292112329045184221253288810141588406161993919504223059898349966569463580186816717074818823215848647734386789115646607551753855522244285240494680336922999893007839206912151774069642857393196910500988278523053797637940257968953295112436166778910585557213381789089945453947915927374958626823784448687203724348883461685629009785053249703693336194243980288236432355380828003875741710969289725499878566253488670330951551845212694498925159639207942145266508516052325614861938282489838000815085351564642761700832096483117944401971780149213345335903336672376719229722069970766055482452247416927774637522135201716231722137632445699154022395494158227418930589911746931773776518735850032318014432883916374243795854695691221774098948611515564046609565094538115520921863711518684562543275478705300069984231401801694211091059254935961167194576396232883127126832850176032177168042496576741869271132155732749935709942324416387089242427584476512155726763792476534180898431267694111031316595142947937767069888124964342193328740439485538222160837088907598277390184241381978110258545370885867014506235785139601099874760525354501439353062072439709976445146790993381448994644609780957731953649387349500268605645556932242296918156302939224876064708734311663842054424896287602136502469918934011251310383508562190806027086660487358584900174200923929789193938125116798421788115209259130435572321635660895603514383883939018953166274355609970015699780289236362349895374653428746875

jonas.t...@gmail.com

unread,
May 26, 2016, 4:47:25 AM5/26/16
to
If someon ask really nice ;), i may write code that do the calculation exceeding the +/- 9007199254740991. And then the calculation is done in no time at all truly linear.

jonas.t...@gmail.com

unread,
May 26, 2016, 4:54:04 AM5/26/16
to
Or maybe you want to learn howto do both division and multiplication in linear time?

https://www.youtube.com/watch?v=LB5YkmjalDg

jonas.t...@gmail.com

unread,
May 26, 2016, 5:58:55 AM5/26/16
to
To be honest i can to much better than linear time using lookup tables for squares, and a search...

Ben Bacarisse

unread,
May 26, 2016, 6:30:21 AM5/26/16
to
jonas.t...@gmail.com writes:
<snip>
> Regarding my code, it may not be beautiful but it certainly does what
> it is meant to do in a miracuous way. Finding Fib nr 100000 and
> printing it in 5 seconds.

That seems to be very slow. On my laptop (newish, but 3 years old now)
I can calculate it in almost no time at all:

$ time ./fib 100000 >x
./fib 100000 > x 0.00s user 0.00s system 44% cpu 0.009 total
$ wc x
1 1 20900 x

> That is a 21033 digit number... so my approach to programming may not
> be so bad afterall...

I think you have a bug. The 100,000th Fibonacci number is 20,899 digits long.

<snip>
--
Ben.

jonas.t...@gmail.com

unread,
May 26, 2016, 6:47:38 AM5/26/16
to
So why not post the result of your calculation?

jonas.t...@gmail.com

unread,
May 26, 2016, 6:51:13 AM5/26/16
to
Den torsdag 26 maj 2016 kl. 12:30:21 UTC+2 skrev Ben Bacarisse:
25974069347221724166155034021275915414880485386517696584724770703952534543511273686265556772836716744754637587223074432111638399473875091309656973821883044935228763853133492135326792789567015127657827163560807350532224323311438398651613782723812477745377833729991621463450054669860398627509966393664092118901252719601721050630035058689402855810367511765825136837743868493641345733883436515877542537191241050332195991330062204363035213756525421823998690848556374080179251761629391754963458558616300762819916081109836526352995440694284206571460449380564713634633000520852277707554446794723709039790191486043284681985796115951018506082649192345873133991513391993236312301864172536477136266475081339824312317343145296418179005118795731676683497990168201184990775668645684506628739248560391404760519955006628882634587718941068037009187936500173301171002831047394745625691444932821374855573864080579813028266640270354294412104919995803131876805899186513425175959911525631553377039969410355182752749199598022575079023779813089922984996304496255814045517000250299764322193462165366210841876745428298261398234478366581588408190330738293950082132093747154851312722081730543226486694963098791471436292555425262404399961532697987687510646819068792118299167964409178271868561702918102212679267413626549978496884368097525470013145741864064482994858725517447466956518791269169932445648176733222571493149677633458466238303338223970243685947828764187578857291071013370300094229333597292779191409212804915459762627915705524815888405177941819295216769576608748815567860128818354354292373978115478570132843861272862017665395344499300198006295389369855007232866513171811358866135374726845854325489811371766051946169379168844253425947812631388952479565943807153019112539648471126389007133628569101551453423329441284357220996286746119420951661023097470996553190058158669911445442647882872642845017253320486483194578920399848938236367456182203750973485668474338872490493370316338265717607297788917989136673251962324711803728017392157239082276922807729245666275053833750069260772159361942126892030256744356537800831830637593334523502569729065152853271943677560156660399164048825639676930792905029514886934137991251748566670747175149389790386533381395346848378086126737554383821108448976538368483182588363399173104558509056638462025014631311831087429077292622159430242915947403061018398168550669502619737615857176119947587572212987205312060791864983615969233959410411863516885488391191851790615115627529361584900087215019222651178531508925102752804515123860379218469212153382928713692432152733271415747882959026015719548531644479454675285840236000238344795203451080332820138038807089807348326201227952633606773669875783326254859449602191736886778624112056210983698519729017715781120404586491539351157834995461006366357454485082418882790675313599505192062229760153765297973085881648731173082370598284894044874039320535929359764541655607954724778620299692329561389719894679422187273605123365595211331087787582288795975803204596084790245063851941743126163775104599211248687949634170686209290889306852523480569259983337751039010131661781230511457193276629167125446512151746802548190358351688971707576778656188008220346836321018130262329960275994035799977740462449521145315883703579044832931500072461734173558055678321534543411700202585608916629419863740151456957227283692196322951118776253075340259478144820465746028848556280693481139827601685558407954216205754355729151064153759293902288435612079264375560062367986544382464373946972471945996555795505838034825597839682776084731530251788951718630722761103630509367426226171736305861329154424695432904616258691774630578507674937487992329181750163484068813465534370997589353607405172909412697657593295156818624747127636468836551757018353417274662607306510451195762866349922848678780591085118985653555434958761664016447588286336297040462890976773625658430235314749461233912068632146637087844699214275415694109122465685712047172411333784898167649692498163342117685715031167104006817530319211541561195804257065869312727621371069747222602965552461105371555453249975843275200199214301915053629960070429632978051036665063878626815765877268374512897685079636637105938091122542883583919412115477375998130192165095214013330607098731373292651816922684506344395405672981203154639232498179378046910379342216949522917930299492375072993250630594281390279308413447306141164335561476409310442591848136393054236937897652052645634764831827263337151211203062923388928648794920973784786188486826804647319539284039830800880386904955741975621929392211082576639768136104449002472948340326796768837621396744757138872928630798218493143438797780887379588968409461434159271317578365114578289355818599292353438888884658745213083813777944363611976283903689459576012031650227985790154534474735270697285145459986142290273729113146378204551622544753535677362279364854503571020864454120898423503890877223039849380214734809687433336225449150117411751570704561050895274000206380497967964026178186644812485472696308234733772455433905198413087697812765659167642290229481817630757102557933650081522863836344931380899717858707086363220586901893837776606300606675773242727292924742129526500076646722730009956124191409138984675224955790729398495608750456694217771551107346630456603944136235888443676215273928597722879373559667239246138274687032178584599482575147454064364609970593161205968415604732343966524572316503177928338605938836041769142873273570398680334264670071717363573091122981306903286137122597937096605775172964528263757434075792282180744352908669606854021718597891166333863858589736209114248432178645039479195424208191626088571069110433994801473013100869848866430721216762473119618190737820766582968280796079482259549036328266578006994856825353643667482253460375134503603152154296943991866236857638062351209884448741138600171173647632126299614856192559970756682786677873237741944446227539990929104469771647615111867232723867928133367306181944849396607123345271856520253643621964198782752978813068031314181706931446822118927578497828109436775154071016350553798003842219045508482239386993296926659221112742698133062300073465628498093636693049446801628553712633412620378491919498600097200836727876650786886306933418995225768314390832484886340318941941613697984383334660867670943164365353843091215781554351285207772085809892099586449602479491970687237656871092343807195098248144731578137800863935841875665509850132188285284018498140769073850736953537771188038852893534760093338598691608289335421147722936561972762646037262723932099118782040767412272258127667294007192423793330972132364184093956102995971291799828299539147382437802779051112309545825328887211461701334403859396540478061993332245473178034073409251213217279595753863158148810392952475410943885550983826276331276067181261710220113561818007754002275167341441692164249731756213631285882819780578883245453458152243493726813343399771051253208147834567139835038332901313945986481820272322043341930929011907832896569222878337497354301561722829115627329468814853281922107523736268276431526857354932230280181014496490091552924863833888566489300225097434360120081436515362536919944670971112695196672578061891215440222487564601554632812091945824653557432047644212650790655282083379760714651275832048716527157747232588727576112835759213255393444628943325815028633583669291828566894736223508250294964065798630809614341696830467595174355313224362664207197608459024263017473392225291248366316428006552870975051997504913985946807101360233644016441791886108532307649917143720544678235972117604651532001630853363193515896458906817223728123103202718979179512727996565369403211124284659099455638021546131610626752163380566439431888126819949400553706869762185523185892110096344101293353573391845966819753983428469682288946007635203168892200202193131836975755696206111577430582630553586201563789124631220672933992617378379625150999935403648731423288739779689089083699962929953919772177965334212492919783837514600620549673416628334873410110977705358980664981360113955715843283087139405825352740560810115039079416880791972129331483030726386786314110384431282159949368243429981887197686376044963425975242568861886889789808883158650762626048564650043228968561492550639688114044004295038942458723822335431010786915173283336047792627277656860761777056168740525774374998377583014385613542727383858977413352694916548392972151955479357892386676250274537010466090938244962662693532130374453889247921616118888970207791044856319951482663080287954954645358386630734442375331971227915886177289652090149848305435983207713266534072906620167757064096901837712013068232453334779666652532549087361961483782415660712716503835822572892157820936951099589013285949072430618332575521208097175220229497428018234454137119162984499147222541965946822214682606449618392542496709031040075814888579716722463228870164384039084638567311643081695373267903311458368057521119639905615169154708510459700542098571797318015564741406172334145847111268547929892443013914682891036791792169786165824897322033591376706527676521371439853027609884780562169946596554613791749856597392273794167264953778019929835542786617912312669937473077773569324430166839333011554515542656864937492128687491217542459678311329692484924667442619993397282567487346020115044222878046612432018301618232183908654771042398228531316559685688052265714744288233175394565438819286244326625033453881995900851521138312449186180262443219554043398572284134125440941177172215686708629174212405311062052284298619927362940620883475485364512812327960909721395377536002307676569420821994303464878334854449271353945022459133437466493770165560576338469706291872574542655879414630176639760457474311081556747091652708748125267159913793240527304613693961169892589808311906322510777928562071999459487700611801002296132345882945584409524966111583428049086438608807964455776369185774375402589685592725251456340438521782589059955395462745138545445291676104296926797089358005623450191857148903041849576740081935997321871195749635709596782517109626475206889080640765144589313287076745416960710793169270428516893413311046353506242209810363216771910420786162184213763938194625697286781413636389620123976910465418956806197323148414224550716172158513213020306841760872158927020988791089380810459033972765473264169168454456276007595613671035845756490944306924525328500309106878315756151984756756919128478465469255866511155791346127242533608363513134218395177154511228464455136016013513228948543271504768393075561009878609666387061227869027483181933160670148495716300470526222823840626681844878837454813199438038761383012885988526420199228618820849958864088852135250145761539648264745102590253074317295689963649961570755185583716593536712544851508936290456773663003556245737477910098799249914696722404148160128953094401548894261378314008780431143174185807182618514951138744831358439067228949482582860216502889272283874264327861686903819605315589445945188735197246008221529343980828254126128257157209359853828007385604729194118460844852353778335033068619777245018863647034497336647310060218128792886991861824418453968994777259482169137133647474531729798092458443611296189975956962409718455642051143258959184472492094293030165148871379802123790655365251547802980594075294405131458755153779486163587991158192019808879694967187448224156836463534326162426329347616344581638901638051238941845239734218414968892623984896486420934981668149477115517709562669029850101513537599801272501241971119871526593747484778935488777815192931171431167444773882941064615028751327709474504763922874890662989841540259358340351420351361688192482389980277666691634213342431205450735938861668769118818577611813577133248396520988208598239129860638682280475436248956522921410859852037330544625953261340234864689275060526893755148403298542869912210525970056285767077256769530097897004648920009852106980295419699802138053295798159478289934443245491565327845223840551240445208226435420656313310702947223715527705426348207398445488958924886139765779145414427653584572951329719091947694411910966797474262675590953832039169673494261360032263077428684105400613510521944137781580950571452684600981035219249042795850736436961021241137739717164869525493114805040126568351268829598413983222676377804500626572417317573952197968907548251993292596498162706866565830178877405615167159731927320479376247375505855052839662945669925221736008740812121420907104193759857172143133801742514158249182471090508471597724941704932025416523932323325885158889333797136310892571531417761978326033751090262840664158013713593565292780884563059517708144399411467429185036074885236665474486992808323051681571160291183637414795849210086052898146954775081233889694315286102120273674704990393417035171342126923486700566627506229058636911882228903170510305406882969708755453293694346398129769647803182545164217834734771647158423238594581830527562139101869976043058440686657123468696794560441557421039179758348979935882751881524675930878928159243492197545387668305684668420775409821781247533545231947973989533201759886402810588255576980439712538312459428957377696001857497335249965013509368925958021863811725906506436882127156815751217129765992750370228283963962915973251173418586721023497317765969454283625519371556009143680329311962842546628403142444370648432390374906410811300792848955767243481200090398884572709077508736388732996425555047381252897596293482287891761992725138309388288292514168376227582408191893360365387528411678570372098971883298692192781662967584458017491180911966304818743415506779086394883148924150430047674527971283482211522228370628573142441078237925136450866775666228049772113971406216641163247567842166129614771090188269467737768640617672148429389497667138012278894139026553511096118347012565197540807953840609168639369066737866272094294342642604029215831734500372746258899262204987712117845563348492490326003585690993823927772974984135656148307882623633223683807098223460122742413790364734517359252157547571609342709351929017239549214264906911152715233381912404281210289373848816735895393450893069771552298919969890388588327540904430032198683400347027122002015969937169065033054757709539874858067002449104550489006172718916803139452803616563394157133463722255047754746075605502410876438212168884891694037125890194849068537972224456200948381949153272450227621858916950745794983759821660448199651936011026157694717620257170248684914616894068404140833587562118319210838005632144562018941505945780025318747471911604840677997765414830622179069338538751292989830095827755414543505876898494417913653589162009872522249055183554603706533183176716110738009786625247488691476077664470147193074476302411660335671765564874440577990531996271632972910944924921645603061882777294775764777446452586328919159107444252320082918209518210837353881330983215894686801279542247520719241346483349639150948130975414332442092999307514810779192346128122331617994299306188005334145506339321393396468616164169552202164479954172431711657444713641977332048993650747678441499295480730258564429423817876415064928783617679786771585107842357026402133880188756019892340568684232155856285864552525837710620532224244987990625263484010774322488172558622333020763999338541520153438477254429178951306370503204449177977523787195827797679968611362653229111862963116468515993466069346055754595663155830033697634000276685151293843638886908283761411577320035275651587459065670254394379311048385713132944906492658236310894953509008267315449722639664808861804157397788847289217461897418972177700098624496537590127270152276345108749694801221068495206302519011655963580552429180205586904259685261047412834518466736938580027700252965356366721619883672428226933950325930390994583168665542234654857020875504617520521853721567282679903418135520629998953664701065579532129541336924472492212436324523428951884617791223386967423398069488727058750338922839509513520912319258159006960395156367736067109050566299635718764232479207528361608055976977787564767672152122232718482148444663126148758422609260887576433173102326376886482259469121103236773755812213347055680595800831012748167396201958359802396741448986727684586981937678375716793672321308158619104599505897099106468691946344803857414382962954713137217366983618455814455748676124322451519943362182916191468026091121793001864788050061351603144350761892134416024880917410512322903571792054979279709245024799408426961588184426161637800447594782122408732041244211691998055726491182436619218357147628914258057718717436880003241130087048193739622950171430900984769272374988759386399425305953316078916188108635598244457894279934651491595288486975748802582335357167786482682805114885429732788197765736966005727700162592404301688659946862983717270595809808730901821209313430058796552694788498092548430546761134654748067296743997636125924346377199958438628123919854702024148800768808188480878923915913694632931132768493297772016466417275872591223547844808134333280500877588552646861195769621722393086937957571658218524162043419723839899327348034292623472233815510229101262949249742423271698842023297303260161790575673111235465890298298313115123607667739689981538122869996420146098525797936912460163460887623212862056342159014791886321946596374834825642916162785329482393132294402310432772887681395502133482663886874532592815878545038909915619496324788550350902893997371898800399902613201587267863787309567810962531100805448941885798356590206368069964316533912029944327726770869305240718416592070961392864019667257508701221814973313369580960036975176495135040285926249203398111149532275336218445007443315624345324842179861083462613458975912348399707518542232816771872159568272432459108290198863936978454262256691254274705697567984857136623679238784781612014779829390805131502581745237735295101652969345627861222411507835877553733483727644398380826672147400344663227769189369676128789834889420946881023084273645285450496675969731883604449670285319063739691635798928865719935397723495486787180416414152814894437850362910715178052858575839877111454742401564164771941163913549354667555935926088492005463846854030280809364172505836533680934072253108208447235702268098269514261624512040407115014487478561999228146645658939384880286438223138498523284523606670458051136796637510392481633361732745472757756368109773445392758275605974251607546868965779453052162315939865780974801515414987097778787053570580084723768924221897503127585271401731176212798987449584061998439133656802977212875193498850449971391428515803232482302134063031258607262454163776523450552251086318285359658520708173392709566445011404055165790550374177803933516583690454347721422281816832539613634982525215232257690920254216409657452618066051777901592902884240599998882753691957540116954696152270401280857579766154722192925655963991820948894642657512288766330302133746367449217449351637147257329808328127264681877593565842183835947027920136639076897417389622525757826639908097926470114075803678505993818871845600946958332707751261812820153910417739509182441375619999378192403624695582359241714787277944844310875190187414112903707060520851629757983617542510416422448675773507563380188953792631833898559559565278572279261555244947393636655339452865621546428834316228292112329045184221253288810141588406161993919504223059898349966569463580186816717074818823215848647734386789115646607551753855522244285240494680336922999893007839206912151774069642857393196910500988278523053797637940257968953295112436166778910585557213381789089945453947915927374958626823784448687203724348883461685629009785053249703693336194243980288236432355380828003875741710969289725499878566253488670330951551845212694498925159639207942145266508516052325614861938282489838000815085351564642761700832096483117944401971780149213345335903336672376719229722069970766055482452247416927774637522135201716231722137632445699154022395494158227418930589911746931773776518735850032318014432883916374243795854695691221774098948611515564046609565094538115520921863711518684562543275478705300069984231401801694211091059254935961167194576396232883127126832850176032177168042496576741869271132155732749935709942324416387089242427584476512155726763792476534180898431267694111031316595142947937767069888124964342193328740439485538222160837088907598277390184241381978110258545370885867014506235785139601099874760525354501439353062072439709976445146790993381448994644609780957731953649387349500268605645556932242296918156302939224876064708734311663842054424896287602136502469918934011251310383508562190806027086660487358584900174200923929789193938125116798421788115209259130435572321635660895603514383883939018953166274355609970015699780289236362349895374653428746875

jonas.t...@gmail.com

unread,
May 26, 2016, 7:00:48 AM5/26/16
to
Den torsdag 26 maj 2016 kl. 12:30:21 UTC+2 skrev Ben Bacarisse:
It is tediously slow get the last digits from wolfram when you not pay, but as long i had time to follow they are correct.

jonas.t...@gmail.com

unread,
May 26, 2016, 7:11:07 AM5/26/16
to
I managed to get it all from Wolfram it is the same number, apparently the online scripts not that good at counting, next time i count characters myself.

Wolfram Alpha

2597406934722172416615503402127591541488048538651769658472477070395253454351127368626555677283671674475463758722307443211163839947387509103096569738218830449305228763853133492135302679278956701051276578271635608073050532200243233114383986516137827238124777453778337299916214634050054669860390862750996639366409211890125271960172105060300350586894028558103675117658251368377438684936413457338834365158775425371912410500332195991330062204363035213756525421823998690848556374080179251761629391754963458558616300762819916081109836526352995440694284206571046044903805647136346033000520852277707554446794723709030979019014860432846819857961015951001850608264919234587313399150133919932363102301864172536477136266475080133982431231703431452964181790051187957316766834979901682011849907756686456845066287392485603914047605199550066288826345877189410680370091879365001733011710028310473947456256091444932821374855573864080579813028266640270354294412104919995803131876805899186513425175959911520563155337703996941035518275274919959802257507902037798103089922984996304496255814045517000250299764322193462165366210841876745428298261398234478366581588040819003307382939500082132009374715485131027220817305432264866949630987914714362925554252624043999615326979876807510646819068792118299167964409178271868561702918102212679267401362650499784968843680975254700131004574186406448299485872551744746695651879126916993244564817673322257149314967763345846623830333820239702436859478287641875788572910710133700300094229333597292779191409212804901545976262791057055248158884051779418192905216769576608748815567860128818354354292307397810154785701328438612728620176653953444993001980062953893698550072328665131718113588661353747268458543254898113717660519461693791688442534259478126310388952047956594380715301911253964847112638900713362856910155145342332944128435722099628674611942095166100230974070996553190050815866991144544264788287264284501725332048648319457892039984893823636745618220375097348566847433887249049337031633826571760729778891798913667325190623247118037280173921572390822769228077292456662750538337500692607721059361942126892030256744356537800831830637593334502350256972906515285327194367756015666039916404882563967693079290502951488693413799125174856667074717514938979038653338139534684837808612673755438382110844897653836848318258836339917310455850905663846202501463131183108742907729262215943020429159474030610183981685506695026197376150857176119947587572212987205312060791864980361596092339594104118635168854883911918517906151156275293615849000872150192226511785315089251027528045151238603792184692121533829287136924321527332714157478829590260157195485316444794546750285840236000238344790520345108033282013803880708980734832620122795263360677366987578332625485944906021917368867786241120562109836985019729017715780112040458649153935115783499546100636635745448508241888279067531359950519206222976015376529797308588164873117308237059828489404487403932053592935976454165560795472477862029969232956138971989467942218727360512336559521133108778758228879597580320459608479024506385194174312616377510459921102486879496341706862092908893068525234805692599833377510390101316617812305114571932706629167125446512151746802548190358351688971707570677865618800822034683632101813026232996027599403579997774046244952114531588370357904483293150007246173417355805567832153454341170020258560809166294198637401514569572272836921963229511187762530753402594781448204657460288485500062806934811398276016855584079542162057543557291510641537592939022884356120792643705560062367986544382464373946972471945996555795505838034825597839682776084731530251788951718630722761103630509360074262261717363058613291544024695432904616258691774630578507674937487992329181750163484068813465534370997589353607405172909412697657593295156818624747127636468836551757018353417274662607306510451195762866349922848678780591085118985653555434958761664016447588028633629704046289097067736256584300235314749461233912068632146637087844699210427541569410912246568571204717241133378489816764096924981633421176857150311671040068175303192115415611958042570658693127276213710697472226029655524611053715554532499750843275200199214301910505362996007042963297805103066650638786268157658772683745128976850796366371059380911225428835839194121154773759981301921650952140133306070987313732926518169226845063443954056729812031546392324981793780469103793422169495229100793029949237507299325063050942813902793084134473061411643355614764093104425918481363930542369378976520526456347648318272633371512112030629233889286487949209737847861884868260804647319539200840398308008803869049557419756219293922110825766397681361044490024720948340326796768837621396744075713887292863079821849314343879778088737958896840946143415927131757836511457828935581859902923534388888846587452130838137779443636119762839036894595760120316502279857901545344747352706972851454599861422902737291131463782045516225447535356773622793648545035710208644541208984235038908770223039849380214734809687433336225449150117411751570704561050895274000206380497967960402617818664481248547269630823473377245543390519841308769781276565916764229022948181763075710255793365008152286383634493138089971785087070863632205869018938377766063006066757732427272929247421295265000706646722730009956124191409138984675224955790729398495608750456694217771551107346630456603944136235888443676215273928597072287937355966723924613827468703217858459948257514745406436460997059316120596841560473234396652457231650317792833860590388360417691428732735703986803342604670071717363573091122981306903286137122597937096605775172964528263757434075792282180744352908669606854021718597891166333863858589736209114248432178645039479195424208191626088571069110433994801473013100869848866430721216762473119618190737820766582968280796079482259549036328266578006994856825300536436674822534603705134503603152154296943991866236857638062351209884448741138600171173647632126029961408561925599707566827866778732377419444462275399909291044697716476151118672327238679208133367306181944849396607123345271856520253643621964198782752978813060080313141817069314468221189275784978281094367751540710106350553798003842219045508482239386993296926659221112742698133062300073465628498093636693049446801628553712633412620378491919498600097200836727876650786886306933418995225768314390832484886340318940194161036979843833346608676709431643653538430912157815543512852077720858098902099586449602479491970687230765687109234380719509824814473157813780080639358418756655098501321882852840184981407690738507369535377711880388528935347600930338598691608289335421147722936561907276264603726027239320991187820407067412272258120766729040071924237930330972132364184093956102995971291799828290009539147382437802779051112030954582532888721146170133440385939654047806199333224547317803407340902512130217279595753863158148810392952475410943880555098382627633127606718126171022011356181800775400227516734144169216424973175621363128588281978005788832454534581522434937268133433997710512532081478345067139835038332901313945986481820272322043341930929011907832896569222878337497354301561722829115627329468814853281922100752373626827643152685735493223028018101449649009015529248638338885664893002250974343601200814365153625369199446709711126951966725780061891215440222487564601554632812091945824653557432047644212650790655208208337976071465127508320487165271577472325887275761128357592132553934446289433258105028633583669291828566894736223508250294964065798630809614341696830467595174355313224362664207197608459024263017473392225291248366316428006552870975051997504913009859468071013602336440164400179188610853230764991714372054467823597211760465153200163085336319351589645890681722372812310320271897917951272799656053694032111242846590994556380215461316106267521633805664394318881268199494005537068697621855231858921100963441012933535733918459668197539834284696822889460076352031688922002021931318369757556962061115774305826305535862015637891246031220672933992617378379625150999935403648731423208873977968908908369996292995391977217796533421249291978383751460062054967341662833487341011097770535898066498136011395571584328308713940582535274056081011503907941688079197212933148303072638678631411038443128215994936824342998188719768637604496342597524256886188688978980888315865076262604856465004322896856149255063968811404400429503894245872382233543101078691517328333604779262727765686076177705616874050257743749983775830143856135427273838589774133526949165483929721519554793578923866762502745370104660909382449626626935321303744538892479216161188889702077910448563199514826630802879549546453583866307344423753319712279158861707289652090149848305435983200771326653407290662016775706409690183771201306823245333477966660525325490873601961480378241566071271650383582257289215708209369510995890132859490724306183325755201208090007175022022949742801823445413711916298449914722254196594682221468260644961839254249670903104007581488857971672246322887016438403908463856731164308169537326790303114583680575021119639905615169154708510459700542098571797318015564741406172334145847111268547929892443001391468289103679179216978616582489007322033591376706527676521307143985302760988478056216994659655461379174985659739227379416726495377801992098355427866179123126699374730777730569324430166839333011554515542656864937492128687049121754245967831132969248492466744261999033972825674873460201150442228780466124320183016108232183908654771042398228531316559685688005226571474428823317539456543881928624432662503345388199590085105211383124491861802624432195540433985722841341254409411771722156867086291742124053110620522842986199273629406208834754853645128123279609097213953775360023076765694208219943034648783348544492713539450224591334374664937701655605763384697062918725745426505879414630176639760457474311081556747091652708748125267159913793240527304613693961169892589808311906322510777928562071999459487700611801002296132304588294558440952496611158342804908643860880796440557763691857743754025896855927252514563404385217825890599553954627451385454452916761042969267970893580056234501918571489030418495767400819359973218711957496357095967825171096264752068890806407651445893132870767454169607107931692704285168093413311046353506242209810363216771910420786162184213763938194625697286781413636389620123976910465418956806197323148414224550071617215851321302030684176087215892702098879108938081045903397276547326416916845445627600759561367103584575649094430692452532085003091068783157561519847567569191284784654692558665111557913461272425336083635131342183905177154511228464455136016013513228948543271504760839307556100908786096663870612278690274831819331606701484957163004705262228238406266818448788374548131994380387613830128859885264201992286188208499588640888521352501457615396482647451025902530743172956899636499615707551855837165935367125448515089362904567736630035562457374779100987992499146967224041481601289530944015488942613783140087804311431741858071826185149051138744831358439067228949408258286021650288927228387426432786168690381960530155894459451808735197246008221529343980828254126128257157209350985382800738560472910941184006084485235377833503306861977724501886364070344973366473100602018128792886991861824418453968994777259482169137133647470453172979809245844361129618997595696240971845564020511432589591844724920942930301651488713079802102379065536525154780298059407529440513145807551537794861635879901158192019808879694967187448224156836463534326160242632934761634458163890163805123894184523973421841496889262398489648642093409816681494771155177009562669029850101513537599801272501241971119871526593747484778935488777815192931171431167444773882941064615028751327709474504763922874890662989841540259350834035142035136168819248238998027706666916342133424312054507359388616687691188185776118135771332483965209882085982391298606386822804754362408956522921410859852037330544625953261340234864689275060526893755148403298542086991221052597005628576707702567695300978970046408920009852106980295419699802138053295798159478289934443245491565327845223840551240445208226435420656313310702940722371552770504263482073984454889589248861397657079145414427653584572951329719091947694411910966797474262675590953832039169673494261360032263077428684105040061351052194413778158095005714526846009810352109249040027958050736436961021241137739717164869525493114805040126568351268829598413983222676377804500626507241731757395219796890754825199329259649801627068665658030178877405615167159731927320479376247375505855052839660294566992522173600874081212014209071041937598571721431338017425141582491824710905084715977249417049320254165239323233258851588893337097136310892571531417761978326033750109026284066415801371359356529278088456305951770081443994114674291850360748852366654744869928083230516815711602911836374147958492100860528981469547750812338896943152861021202736747049903930417035171342126923486700566627506229058636911882228903170510305406882096970875545329369434063981297696478031825451642178347347716471058423238594580183052756213910186997604305844068665712346869679456044155742100039179758348979935882751881524675930878928159243492197545387668305684668420775409821781247053354523194797398953320175988640281058825557698004397120538312459428957377696001857497335249965013509368925958021863811725906506436882127156815751021712900765992750370228283963962915973251173418586721023497317765969454283625519371556009143680329311962842546628403142444370648432390374906410811300792848955767243481200090309888457270907750873638873299642555050473812528975962934822878917619920725138309388288292510416837622758204081918933603653875284116785703720989718832986921927816629675844580174911809119663048187434155067790863948831489241504300476704527971283482211522202837062857314244107823792513645086677566622804977211397140621664116324756784216612961477109018826094677377686406176721484293894976671380122788941309026553511096118347012565197540807095384060916863936906673786627209429434264260402902158317345003727462588992622049877121178405563348492490326003508569099382392777297498413565614830788262363322368380709822346012274241379036473451735925215754757160934270935192901723954921426490691115271523338109124042812102893738488167358953934508930697715522989199698903885883275409044300321986834003470271220020159699371690650330547577095398748580670024491045504890061727189168031394528036165633941571334637222550477547460756055024108764382121688848916940371258901948490685379722244562009483819491532724502276218589169507405794983759821006604481996519360110261576947176202571702048684914616894068404140833587562118319210838005632144562018941505945780025318747471911604840677997765414830622179069330853875129298983009580277554145435058768984944179136535891620098725222049055183554603706533183176716110738009786625247488691476077664470147193074476302411660335671765564874440577990531996271632972009109449249216456030618827772947750764777446452586328919159107444252320082918209518021083700353881330983215894608680127954224752071924134648334963915094813097541433244209299930751481077919002346128122330161799429930618800533414550633932139339646861616416955220216447995417243171165744471364197733204899365074767844149929548073025856442942381787641506492878361767978677158510784235702640213388018875601989234056868423215585628508645525258377010620532224244987990625263484010774322488172558602233302076399933854152015343847725442917895130637050320444917797752370871958277976799686113626532291118629631164685159934660693460557545956063155830033697634000276685151293843638886090828376141157732003527565158745906567025439437931104838571313294490604926582363108949535090082673154497226396648088618041573977888472892174618974189721700770009862449653759012727015227634510874906948012210684952063002519011655963580552429180205586904259685261047412834518466736938580027700252965356366721619883672428226933950325930390994583168665542234654857020875504617520521853721567282679903418135520602999895366470106557900532129541336924472492212436324523042895188461779122338069674233980694887270587503389228395095135209123109258159006960395156367736067109050566299603571876423247920752836160805597697778756476767210521222327184821484446631261487584226092608875764331731023263768864822594691211032367737558122133470556805958008310127481673962019583598023967414489867276845869819376783757167936723213081586191045995058970991064686919463448038574143829629547131372173669836184558144505748676124322451519943362182916191468026091121793001864788050061351603144350076189213441602488091741051232290357179205497927970924502479940842696158818442616163780044759478212240873204124421169199805572649118243661921835714762891425805771871743688000324113008704819373962295017143090098476927237498875938639942530595331607891618810863505982444578942799346514915952884869757488025823353571677864826828051140885429732788197765736966005727700162592404301688659946862983717270595809808730901820120931003430058796552694788049809205484305467611034654748067290674399763612592434637719995843862812391985470202414880076880818848087892391591369463293113276849329777201646641727587259122354784480813433328050087758855264686119576962172239308693795757165821852416204341972383989932734803429262340722338155102209101262949249742423271698842023297303260161790575673111235465890298298313115123607606773968998153812286999642014609852579793691246016346088762321286205634215901479188632194659637483482564291616278532948239313229440231043277288768139550213348266388687453259281587854503890991561949632478855035090289390973718988003999026132015872678637873095678109625311008054489418857983565902063680699643165033912029944327726770869305240718416592070096139286401966725750087012218149733133695809600369751764951350040285926249203398111014953227533621844500744331562434532484217986108346261345897591234839970751854223281677187215956827243245910829019886390369784542622566912542747056097567984857136623679023878478161201477982939080513150258174523773529510165296934562786122241150783587755373348372764439838082000667214740034466322776918936967612878983488942094688102308427036452854504966759697318836044496702853190637396916357980928865719935397723495486787180416401415281489443785036291071517805285857583987711145474240156416477194116391354935466755593592608849200546384685403028080936417250583653368093407225310820844723570226809826951426162451204040711501448747856199922814664565893938488028643822313849852328452360667045805113679663751039248163336173274547275775636810977344539275827560597425160705468689657794530521602315939865780974801515414987097778078705357058008472376892422189750312758527140173117621279898744958406199843913365680297721208751934988504499713914285158032324823021340630312586072624541637765234505522051086318285359658520708173392709566445011404055106579055037417780393351658360904543047721422281816832539613634982525215232257690920254216409657452618066051777901592902884240599998882753691957540116954696152270401280857579766154722192925655963991820948894642657512288766330302133746367449217449351637104725732980832812726468187759356584218383594702792013663907689741738962252575782663990809792647011407580367850599381887184560094695833270775126181282015391041773950918244137561999937819240362469558235924171478702779448443108751901807414110290370706052085162975798361754251041642244867577350756338018895379263183389855955956527857227926155524494739363665533904528656215464288343162282921123290451842212532888101415884061619939195042230059898349966569463580186816717074818823215848647734386780911564660755175385552224428524049468033692299989300783900020690121517740696428573930196910500988278523053797637940257968953295112436166778910585557213381789089945453947915927374958600268237844486872037243488834616856290097850532497036933361942439802882364323553808208003875741710969289725499878566253048867033095150518452126944989251596392079421452606508516052325614861938282489838000815085351564642761700832096483117944401971780149213345335903336672376719229722069970766055482452247416927774637522135201716231722137632445699154022395494158227418930589911746931773776518735850032318014432883916374243795854695691221774098948611515564046609565094538115520921863711518684562543275047870530006998423140180169421109105925493596116719457630962328831271268328501760321771680400249657674186927113215573270049935709942324416387089242427584407651215572676037924765341808984312676941110313165951429479377670698881249643421933287404390485538222160837088907598277390184204138197811025854537088586701450623578513960109987476052535450100439353062072439709976445146790993381448994644609780957731953604938734950026860564555693224229691815630293922487606470873431166384205442489628760213650246991893040112513103835085621908060270866604873585849001704200923929789193938125116798421788115209259130435572321635660895603514383883939018953166274355609970015699780289236362349895374653428746875

Ben Bacarisse

unread,
May 26, 2016, 9:13:26 AM5/26/16
to
What would be the point? We all know what the number is.

--
Ben.

Michael Haufe (TNO)

unread,
May 26, 2016, 9:40:07 AM5/26/16
to
On Thursday, May 26, 2016 at 12:57:04 AM UTC-5, jonas.t...@gmail.com wrote:
> Den torsdag 26 maj 2016 kl. 02:22:46 UTC+2 skrev Michael Haufe (TNO):
> > On Tuesday, May 24, 2016 at 7:38:51 AM UTC-5, jonas.t...@gmail.com wrote:
> > >
> > > I am not sure what all the prescriptions is all about but i sure find them annoying.
> >
> > Prescription drugs? That would explain a bit...
>
> The nonsense ads, i find them annoying. For some reason there usually comes a dozen or so as soon i post some code.

The drug peddlers are trying to help. Maybe you should try some.

> If there is no speed gain i think i keep the simpleton / naive approach.

How would you know in your case? How are you measuring? simply wall clock speed and task manager? Naive indeed.

> I think beginners in programming will favour understanding that code. When i look at recursive code it look so entangled.

Recursion of that type is also called induction. It's a perfectly valid and has a long history:

<https://en.wikipedia.org/wiki/Mathematical_induction#Description>

It's also a different way of thinking from what the current main-stream programming languages emphasize (Algol descendants).

> The operations seems snared into the execution part, with c=a; a=b; b=c; there is really no doubt about what is happening whether you use a for or a while loop.

The point of Dynamic Programming is to solve a problem by breaking it into sub-problems that can be re-used: either by memoizing, or by identifying some overlap between the sub-problems.

Recursion is a separate concept, but it makes the explanations shorter and cleaner.

> Regarding my code, it may not be beautiful but it certainly does what it is meant to do in a miracuous way. Finding Fib nr 100000 and printing it in 5 seconds.

I've already demonstrated from my earlier link that fib(n) can be found in O(1)/O(1), so it's a moot point. Printing the value of fib(n) is a separate concern and is generally I/O bound. Just like how I can find Infinity in O(1):

var i = Infinity

But I can't print the actual value of it in any amount of given time.

> That is a 21033 digit number... so my approach to programming may not be so bad afterall...

Given the large volume of questions you post here, the evidence seems to disagree

> And ***I*** did calculate and wrote it out using 2k of code in javascript, a feat you and the other simpletons of this group ;) would not dream of without the help from my code.

You're right. I can't dream of writing 2Kb of code to print out a fib(n)

Michael Haufe (TNO)

unread,
May 26, 2016, 9:42:28 AM5/26/16
to
On Thursday, May 26, 2016 at 3:54:04 AM UTC-5, jonas.t...@gmail.com wrote:

> Or maybe you want to learn howto do both division and multiplication in linear time?

So if I multiply by 5000 it will take 5000 steps? I think I'll pass...

Michael Haufe (TNO)

unread,
May 26, 2016, 10:05:36 AM5/26/16
to
On Thursday, May 26, 2016 at 5:47:38 AM UTC-5, jonas.t...@gmail.com wrote:

> So why not post the result of your calculation?

The entire point of an expression is to avoid having to write-out a tediously long and awkward to use value. It simply expresses the value. Hence the name.

Dr J R Stockton

unread,
May 27, 2016, 6:46:37 PM5/27/16
to
In comp.lang.javascript message <874m9ln...@bsb.me.uk>, Thu, 26 May
2016 11:30:14, Ben Bacarisse <ben.u...@bsb.me.uk> posted:
It is indeed, between 2.5e20898 and 2.6e20898, ... just over
+2.59740693472217241661550340212759154148804853865176965847247707e20898


--
(c) John Stockton, Surrey, UK. 拯merlyn.demon.co.uk Turnpike v6.05 MIME.
Merlyn Web Site < > - FAQish topics, acronyms, & links.


0 new messages