trekhleb / javascript-algorithms

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

fix(fastPowering): check when number is raided to power of one #1055

Open jaw0r3k opened 11 months ago

jaw0r3k commented 11 months ago

The function didnt check when power is one so unnecessarily was going though multiplying base by ones

lazarljubenovic commented 10 months ago

This type of benchmark is usually not a good measurement for practical usage. More importantly, this type of "optimization" is not the goal of this repository -- it's about understanding data structures and algorithms, not squeezing out every nanosecond from the engine.