<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var m = parseInt(prompt("请输入第一个数"))
var n = parseInt(prompt("请输入第二个数"))
//最大公约数
function fnA(m, n) {
var x = m * n
while (m * n != 0) {
if (m > n) {
m = m % n
}
else {
n = n % m
}
}
var x = x / (m + n)
// 两个数的最小公倍数会等于两个数的乘积除以两个数的最大公约数的结果
// var x=(m*n)/(m+n)
document.write(x)
document.write('</br>')
return [m + n, x]
}
function fnB(m, n) {
alert('最大公约数是'+fnA(m, n)[0] + "," +'最小公倍数是'+ fnA(m, n)[1]);
}
fnB(m, n)
</script>
</body>
</html>