Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure I understand how a speed benefit would be had here, since to get number N+1 they still need to retrieve (and/or calculate) number N-1. The difference between getting (N and N-1) or only N-1 is negligible, especially for large n, unless I'm missing something? It's not really more parallelizable either.


Ah, yes, I've read the part about multiplying, and skipped over the real code. My bad.

The benefit would be there, if Dickens went one step further, and used Math.pow to get the result instead of loop (that is - assuming calculating the power is faster than doing a loop (but it should be - you can square a few times to get near the result instead of multiplying "by one factor" each time)).


Now I see, yeah that would improve it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: