1 2 3 4 5 6 7 | int fact(n) { if (n === 0) { return 1; } else { return n * fact(n - 1); } } |
1 2 3 4 5 6 7 | int fact_i(n) { let result = 1; for (let i = n; i > 0; i--) { result = result * i; } return result; } |
1 2 3 4 5 6 | int gcd(x, y) { if (y == 0) { return x; } return gcd(y, x % y); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |