trekhleb / javascript-algorithms

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

Mahale harsh patch 1 #1582

Open MahaleHarsh opened 2 weeks ago

MahaleHarsh commented 2 weeks ago

applied the reduce method to iteratively compute the LCM across all numbers in the array, combining each pair of results. Additionally, I used the Euclidean algorithm for GCD calculation, which optimizes the LCM computation by reducing the multiplication size.