今天我的一位同事在微信群里发了一张图片,勾起了我的好奇心:不同编程语言支持的函数递归调用的最大嵌套层数是?
?class="hljs cpp">monospace; font-size: 13px; color: inherit; background-color: transparent; border-radius: 0px; padding: 0px; border: none; vertical-align: middle;" class="cpp">
function">private static void recur(int i){
System.out.println("Stack level: " + i);
recur(++i);
}
测试结果:8644
?Chrome版本:
Version 70.0.3538.102 (Official Build) (64-bit)
javascript">
function a(i){
console.log("stack level: " + i)
a(i+1);
}
a(0);
测试结果:11412
?nodejs version: v8.11.3
?测试结果:11213
版本:
? ?测试结果:3947556
?
data: lv_temp type int4.
form recur using iv type int4.
sy-index = iv.
lv_temp = iv + 1.
perform recur using lv_temp .
endform.
START-OF-SELECTION.
perform recur using 0.
实际上是out-of-memory错误。
?测试结果:12258206
?要获取更多Jerry的原创文章,请关注公众号"汪子熙":
?