[go: nahoru, domu]

Skip to content

Commit

Permalink
Update 01.Recursive-Algorithm.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itcharge committed May 13, 2024
1 parent cdcd526 commit c94b3a5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
举个简单的例子来了解一下递归算法。比如阶乘的计算方法在数学上的定义为:

$fact(n) = \begin{cases} 1 & \text{n = 0} \cr n * fact(n - 1) & \text{n > 0} \end{cases}$
$fact(n) = \begin{cases} 1 & \text{n = 0} \cr n \times fact(n - 1) & \text{n > 0} \end{cases}$

根据阶乘计算方法的数学定义,我们可以使用调用函数自身的方式来实现阶乘函数 $fact(n)$ ,其实现代码可以写作:

Expand Down

0 comments on commit c94b3a5

Please sign in to comment.