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

Elegant as fuck

Name: Anonymous 2011-05-15 20:42

def fib(times):
    a, b = 0,1
    for _ in range(times):
        a, b = b, a+b
    return a


I think I just creamed my pants.

Name: Anonymous 2011-05-16 1:36

How's this?

int fib (int a, int b, int n)
{
    if (n) return fib (b, a+b, n-1);
    else return a;
}

and you call it like this:

fib (1, 1, times)

All in glorious C.

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