Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Smaug123
on July 15, 2020
|
parent
|
context
|
favorite
| on:
Data structures and algorithms I actually used whi...
Instead of recursing twice, recurse once, by carrying around not fib(n-1) but the pair (fib(n-2), fib(n-1)).
dotancohen
on July 15, 2020
[–]
True, but then the "worker" fib() method should be called fib_calculate() and should be wrapped by fib() which then returns a single integer. I believe that breaks the spirit of the question.
Taek
on July 15, 2020
|
parent
|
next
[–]
Really it's about this type of discussion. Already with your 'but then' you are showing that you know your way around a program.
I'd still have you write the full thing out, but I'm guessing you'd do just fine.
Smaug123
on July 17, 2020
|
parent
|
prev
[–]
I'd use `go`, by ancient Haskell law and custom ;)
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: