Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

smallest common multiple javascript

const gcd = (a, b) => b == 0 ? a : gcd (b, a % b)
const lcm = (a, b) =>  a / gcd (a, b) * b
const lcmAll = (ns) => ns .reduce (lcm, 1)
const rng = (lo, hi) => [...Array (hi - lo + 1)] .map ((_, i) => lo + i)

const lcmRng = (lo, hi) => lcmAll (rng (lo, hi))

console .log (lcmRng (1, 13))
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: stringify 
Javascript :: datalist example 
Javascript :: javascript reading query parameter 
Javascript :: react-native-checkbox in a loop 
Javascript :: function sytax js 
Javascript :: comprimento string javascript 
Javascript :: Sorting an array of objects on both ascending and descending order on same click 
Javascript :: reactjs absolute import 
Javascript :: check if mobile view javascript 
Javascript :: how to make sure footer is fixed at bottom of page 
Javascript :: jquery on enter click 
Javascript :: array of characters to stirng javascript 
Javascript :: convert shp to geojson python 
Javascript :: remove stack header bottom line react native 
Javascript :: jest mock react router params 
Javascript :: discord.js ticket system stackoverflow 
Javascript :: typeerror object(...) is not a function react useParams 
Javascript :: javascript toggle value 
Javascript :: javascript make element invisible 
Javascript :: javascript clear table body 
Javascript :: fetch post data 
Javascript :: a cypress command to refresh the whole page 
Javascript :: Count Backwards With a For Loop 
Javascript :: bootstrap modal popup disable click outside 
Javascript :: useFetch custom hook for React 
Javascript :: sticky operations in javascript 
Javascript :: phone number validation regex 
Javascript :: get all keys of object in javascript 
Javascript :: H. Nazmul 
Javascript :: react native text truncate 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =