function gcd(a, b) { // 基本情况:如果b为0,则最大公约数为a if (b === 0) { return a; } // 递归调用:计算a和b的余数的最大公约数 return gcd(b, a % b); } console.log(gcd(12, 8));