编写程序,计算出1!+2!+3!+4!+5!+6!+7!+8!+9!+10!.用visual basic 语言
展开全部
可以把这个分成两个循环
一个是1到10的阶乘和的循环
一个是求第i个数的阶乘的循环
--------------------------------------
Private Sub Form_Click()
Dim i As Integer, j As Integer, n As Long, sum As Long
For i = 1 To 10
n = 1
For j = 1 To i
n = n * j
Next j
sum = sum + n
Next i
Print sum
End Sub
---------------------------------------
其中n的值分别1,2,3……10的阶乘
sum就是最后的和
一个是1到10的阶乘和的循环
一个是求第i个数的阶乘的循环
--------------------------------------
Private Sub Form_Click()
Dim i As Integer, j As Integer, n As Long, sum As Long
For i = 1 To 10
n = 1
For j = 1 To i
n = n * j
Next j
sum = sum + n
Next i
Print sum
End Sub
---------------------------------------
其中n的值分别1,2,3……10的阶乘
sum就是最后的和
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Click()
Dim i As Integer, x As Long, sum As Long
x=1:sum=0
for i=1 to 10
x=x*i
sum=sum+x
next i
print sum
End Sub
Dim i As Integer, x As Long, sum As Long
x=1:sum=0
for i=1 to 10
x=x*i
sum=sum+x
next i
print sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询