recursion
🪆 A function solving a big problem by calling a smaller self
Function calling itself on a smaller subproblem.
中文对照 · Chinese
🪆 俄罗斯套娃:大函数里打开小一号的自己
把 n 的问题变成 n-1 的同类子问题(如斐波那契数列和汉诺塔)。
Code example
int fact(int n){ return n<=1 ? 1 : n*fact(n-1); }Explore 100 bilingual word cards →