trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
185.24k stars 29.89k forks source link

Redundant condition #378

Open BnayaZil opened 4 years ago

BnayaZil commented 4 years ago

https://github.com/trekhleb/javascript-algorithms/blob/dc1047df725117c411959692a1ab538f65342b2e/src/algorithms/math/fibonacci/fibonacci.js#L13

This condition is redundant, the while condition covers the case where n equals 1.

p.s- I will exploit this opportunity to say thank you for this repository.

BnayaZil commented 4 years ago

Actually, if u want to be bolt prof u better check n for being greater than or equal to 1.

ricardo93borges commented 4 years ago

I created a PR that removes that condition: https://github.com/trekhleb/javascript-algorithms/pull/400