您的位置首页百科词条

VB求1到N的阶乘

VB求1到N的阶乘

的有关信息介绍如下:

VB求1到N的阶乘

Dim n, i, j As Integer, S, Si As LongDo While .T. n = InputBox("帆昌悉请输入小于13的数", "n=", 0) If n >= 13 Then MsgBox ("请重新输入小于13的数据") Else Exit Do End IfEnddoS = 0For i = 1 To n Si = 1 For j = 2 To i Si = Si * j Next S = S + SiNextPrint "S = 1!态乎+2!+3!+···+n! = "迅掘; Format(S)