Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Scalable Fibonacci Solutions

Name: Anonymous 2011-10-03 18:50

Name: Anonymous 2011-10-03 20:20

var fibonacci = function(n, callback) {
    if (n <= 2) {
        callback(null, 1);
        return;
    }
    async.series({
        n2: function(next) {
            process.nextTick(function() { fibonacci(n - 2, next); });
        },
        n1: function(next) {
            process.nextTick(function() { fibonacci(n - 1, next); });
        },
    }, function(err, results) {
        callback(null, results.n1 + results.n2);
    });
}


Well, I'm convinced! Multiprocessing is for chumps!
For my next web service I'm going full-out single threaded. It's web scale.

Name: Anonymous 2011-10-03 20:23

I don't know JavaScript and therefore have no idea what this code does.

Name: Anonymous 2011-10-03 20:51

I don't know English and therefore I am not entirecfjskbkahakjnflsmdffsjasfhashadg,xncv

heil hitler

Name: Anonymous 2011-10-03 23:15


(f_n)^2 + (f_(n+1))^2 = f_(2n+1)


will give you the odd term ones, and then you can use:


f_(2n) = f_(2n+1) - f_(2n-1)


to get the even ones.

[code]
f_(2(n+1)+1) = f_(2n+3)
             = f_(2n+2) + f_(2n+1)
             = f_(2n+1) + f_(2n) + f_(2n+1)
             = 2f_(2n+1) + f_(2n)
             = 2f_(2n+1) + f_(2n+1) - f_(2n-1)
             = 3f_(2n+1) - f_(2(n-1)+1)
             = 3[(f_n)^2 + (f_(n+1))^2] - [(f_(n-1))^2 + (f_n)^2]   Using Strong induction..
             = 3(f_n)^2 + 3(f_(n+1))^2 - (f_(n-1))^2 - (f_n)^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n-1))^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n+1) - f_n)^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - ((f_(n+1))^2 - 2f_(n+1)f_n + (f_n)^2)
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n+1))^2 + 2f_(n+1)f_n - (f_n)^2
             = (f_n)^2 + 2(f_(n+1))^2 + 2f_(n+1)f_n
             = (f_(n+1))^2 + (f_n)^2 + 2(f_n)f_(n+1) + (f_(n+1))^2
             = (f_(n+1))^2 + (f_n + f_(n+1))^2
             = (f_(n+1))^2 + (f_(n+2))^2

Name: Anonymous 2011-10-03 23:16

>>5

f_(2(n+1)+1) = f_(2n+3)
             = f_(2n+2) + f_(2n+1)
             = f_(2n+1) + f_(2n) + f_(2n+1)
             = 2f_(2n+1) + f_(2n)
             = 2f_(2n+1) + f_(2n+1) - f_(2n-1)
             = 3f_(2n+1) - f_(2(n-1)+1)
             = 3[(f_n)^2 + (f_(n+1))^2] - [(f_(n-1))^2 + (f_n)^2]   Using Strong induction..
             = 3(f_n)^2 + 3(f_(n+1))^2 - (f_(n-1))^2 - (f_n)^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n-1))^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n+1) - f_n)^2
             = 2(f_n)^2 + 3(f_(n+1))^2 - ((f_(n+1))^2 - 2f_(n+1)f_n + (f_n)^2)
             = 2(f_n)^2 + 3(f_(n+1))^2 - (f_(n+1))^2 + 2f_(n+1)f_n - (f_n)^2
             = (f_n)^2 + 2(f_(n+1))^2 + 2f_(n+1)f_n
             = (f_(n+1))^2 + (f_n)^2 + 2(f_n)f_(n+1) + (f_(n+1))^2
             = (f_(n+1))^2 + (f_n + f_(n+1))^2
             = (f_(n+1))^2 + (f_(n+2))^2


more readable. sorry...

Name: kodak_gallery_programmer !!1ILcdKBYf7nyXyy 2011-10-04 0:00

>>6
Wow you blow. This can be proven in 8 lines using a proper proof by induction. But if I go your route, and omit both the Inductive base and the Inductive Hypothesis, I could actually do the proof in 2 lines.

Name: Anonymous 2011-10-04 0:10

>>7

I would like to see...

Name: Anonymous 2011-10-04 0:26

>>8
Maybe something like the following..

Assume F_1 + F_3 + ... + F_2k-1 = F_2k - 1
Show F_1 + F_3 + ... + F_2(k+1)-1 = F_2(k+1) - 1
LHS = F_1 + F_3 + ... + F_2k-1 + F_2k+1 = F_2k - 1 + F_2k+1
    = F_2(k+1) - 1 = RHS


LHS

Name: Anonymous 2011-10-04 1:09

>>7
I've never seen this faggot ever say anything nice. I bet you got mistreated a lot during your childhood. Reverse karma indeed, bitch.

Name: Anonymous 2011-10-04 4:44

My solution is far faster and more user-friendly.
Enjoy your "non-blocking" bloatware.
http://www.reddit.com/r/Nodescripts/comments/l0cce/enterprise_fib_server/

Name: Anonymous 2011-10-04 5:05

>>11
What if you benchmark it against 10k clients?

Name: Anonymous 2011-10-04 5:15

>>12
I'd rewrite it in C then.

Name: Anonymous 2011-10-04 5:20

Which Kiki Kaikai would you scalably compute Fibonacci numbers with?

Name: Anonymous 2011-10-04 5:30

>KiKi KaiKai (奇々怪界?, lit. "Mysterious Ghost World")[2] is a multi-directional shooter developed and published by Taito Corporation originally for Japanese arcades in 1986.

Don't change these.
Name: Email:
Entire Thread Thread List