一道VB题Private Sub Commad ClickPrint "s=";s(5)End SubPrivate Function s(n As Integar )As IntegarIf n=1,Then S=1Elses=s(n-1)*nEnd IfEnd function为什么输出的s值为120

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 14:34:02
一道VB题Private Sub Commad ClickPrint
x){e0fe%*&)8&(8d&gJm5L5]R@J`JK25.$]zE3G < x0B=Ǘv6C3n^l>_7=O(}ﳩt@SU0=

一道VB题Private Sub Commad ClickPrint "s=";s(5)End SubPrivate Function s(n As Integar )As IntegarIf n=1,Then S=1Elses=s(n-1)*nEnd IfEnd function为什么输出的s值为120
一道VB题
Private Sub Commad Click
Print "s=";s(5)
End Sub
Private Function s(n As Integar )As Integar
If n=1,Then S=1
Else
s=s(n-1)*n
End If
End function
为什么输出的s值为120

一道VB题Private Sub Commad ClickPrint "s=";s(5)End SubPrivate Function s(n As Integar )As IntegarIf n=1,Then S=1Elses=s(n-1)*nEnd IfEnd function为什么输出的s值为120
这是计算n!的函数,s(5) = 5×4×3×2×1
当然是120