function solution(n, m) {
const answer = [];
let max = [];
let min = 1;
for (let i = 0; i <= m; i++) {
if (n % i === 0 && m % i === 0) {
max.push(i);
}
}
answer.push(Math.max(...max));
while (true) {
if (min % n === 0 && min % m === 0) {
break;
}
min++;
}
answer.push(min);
return answer;
}