Better HN
topnewbestaskshowjobs
Log inSign up

emdezpk

1 karma · joined Feb 15, 2013 (13y ago) · 1 submissions

Submissions

comment 13y ago · link · parent

That a terrible C implementation.

It uses recursion, while a simple loop will suffice. Your fib(10000000000) will blow your RAM limit with growing stack (and will be slow) while implementation with loop would consume zero RAM and would run several times faster.

"And as if by magic, there's no need for conditionals" : also incorrect. You have a conditional in int res = (fn[(n < 2)])(n); specifically the (n < 2) part. All you have done after the hard work is moving conditional from one line to another.

"But we're still not sure of which branch we took." - So why don't you put the breakpoint

before* the condition occurs, and step through it in the debugger??