一道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/12/28 04:40:27
一道VB题PrivateSubCommadClickPrint"s=";s(5)EndSubPrivateFunctions(nAsIntegar)AsIntegarIfn=1,ThenS=1Else
一道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