我想要知道 階乘相加的程式怎麼寫
(是vb2005版本的)
題目是這樣 1!+3!+5!=?
請寫出程式顯示結果
請各位大大給我指點迷津謝謝
有個地方我一直轉不過去!!
2006-12-17 16:02:19 · 1 個解答 · 發問者 ☆♀MSB♂★ 2 in 電腦與網際網路 ➔ 程式設計
Private Sub Command1_Click()
Dim a As Integer, sum As Integer, i As Integer, j As Integer, n As Integer
n = 5 ' up to 1! + 3! + ... + n!
sum = 0
For i = 1 To n Step 2
a = 1
For j = 2 To i
a = a * j
Next j
sum = sum + a
Next i
Print sum
End Sub
2006-12-17 21:04:13 · answer #1 · answered by JJ 7 · 0⤊ 0⤋