Deviopath › JavaScript

GCD and LCM

Medium · Math

Write a function gcdLcm that takes two positive whole numbers and returns an object { gcd, lcm }.

gcd is the greatest common divisor (the largest number that divides both). lcm is the least common multiple (the smallest number both divide into). Hint: lcm = a * b / gcd.

Next: Missing Number