JavaScript 函数求和:计算 m 到 n 之间的整数总和
function sum(m, n) { let result = 0; for (let i = m; i <= n; i++) { result += i; } return result; }
// Example: console.log(sum(2, 5)); // Output: 14 (2+3+4+5 = 14)
原文地址: http://www.cveoy.top/t/topic/jCiF 著作权归作者所有。请勿转载和采集!