

The Six Most Common Species Of Code - peterkchen
http://www.willa.me/2013/11/the-six-most-common-species-of-code.html#hn

======
himal
Previous discussion:
[https://news.ycombinator.com/item?id=6711192](https://news.ycombinator.com/item?id=6711192)

------
kozikow
False. Math phd would probably write O(log n) based on either multiplying
[[1,0], [1,1]] matrix or compute it directly for smaller numbers and return
the rounded power of golden ratio for higher numbers.

Notice that for big enough numbers psi becomes insignificant enough, so that
we can only use phi.

------
shoyer
Everybody (except the Math PhD) writes the naive O(2^n) solution? Fat
chance...

------
Justsignedup
That is preposterous! At a hackathon they would probably just return 10 or
something.

    
    
        int fib(int val) { return 10; } // todo: implement me

~~~
mcpherrinm
Certainly the version they gave is too much typing! Maybe something more like

    
    
       fn f(i: int)->int{[1,1,2,3,5,8,13,21][i]};
    

Need more values? copypaste from the online encyclopedia of integer sequences.

------
tomphoolery
my code is the cat code

