Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Least common multiple from array

const lcm = (...arr) => {
  const gcd = (x, y) => (!y ? x : gcd(y, x % y));
  const _lcm = (x, y) => (x * y) / gcd(x, y);
  return [...arr].reduce((a, b) => _lcm(a, b));
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: Don’t Use If-Else and Switch in JavaScript, Use Object Literals 
Javascript :: date range picker react 
Javascript :: window.addeventlistener multiple events 
Javascript :: css javascript 
Javascript :: e parameter in javascript 
Javascript :: react route path 
Javascript :: js create nested object from fields 
Javascript :: add to a js object 
Javascript :: how to prevent clickjacking in react js 
Javascript :: read string using stream nodejs 
Javascript :: javascript detect when youtube video ends 
Javascript :: js what does var mean 
Javascript :: typescript compile string to js 
Javascript :: array within array javascript 
Javascript :: document.ready javascript 
Javascript :: js queryselector 
Javascript :: what is syntactic sugar javascript 
Javascript :: javascript open method 
Javascript :: jQuery - Chaining 
Javascript :: Authentication handling in javascript 
Javascript :: detect system dark mode tailwind css 
Javascript :: property binding angular 
Javascript :: reactjs 
Javascript :: babel minify plugin 
Javascript :: context api example in react 
Javascript :: concate array to string javascript 
Javascript :: toast show pb 
Javascript :: asynchronous javascript 
Javascript :: sessionstorage in js 
Javascript :: express nodejs 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =