更新时间:2022-09-12 14:10:52
今天我的一位同事在微信群里发了一张图片,勾起了我的好奇心:不同编程语言支持的函数递归调用的最大嵌套层数是?
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)
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