(프로그래머스) 최대공약수와 최소공배수

유지원·2022년 5월 8일
0

프로그래머스

목록 보기
46/66

문제 링크

https://programmers.co.kr/learn/courses/30/lessons/12940?language=javascript


Javascript

function greatestCommonDivisor(a, b) {return b ? greatestCommonDivisor(b, a % b) : Math.abs(a);}
function leastCommonMultipleOfTwo(a, b) {return (a * b) / greatestCommonDivisor(a, b);}
function solution(n, m) {
    return [greatestCommonDivisor(n, m),leastCommonMultipleOfTwo(n, m)];
}
profile
👋 https://github.com/ujw0712

0개의 댓글