Skip to content

Recursion: base case and recursive case · ⁨递归:终止条件与递归情形⁩

English

A function that calls itself

  • Recursion is when a function calls itself to solve a smaller version of the same problem.
  • It needs two parts: a base case that stops, and a recursive case that shrinks the problem.
  • Without a base case, it would call itself forever and crash.
中文

会调用自己的函数

  • 递归是指一个函数调用它自己,来解决同一个问题的更小版本。
  • 它需要两个部分:一个能停下来的终止条件,和一个让问题变小的递归情形。
  • 没有终止条件,它就会永远调用自己然后崩溃。

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩