VB 循環結構題目用for……to……step語句計算:1/1+1/(2!)+1/(3!)+1/(4!)+……1/(n!
題目:
VB 循環結構題目
用for……to……step語句計算:1/1+1/(2!)+1/(3!)+1/(4!)
+……1/(n!)
解答:
當N較大時,N!會出錯.
請看:
Dim i As Long
Dim sinTemp As Single
Dim sinSum As Single
sinSum = 1#
sinTemp = 1#
For i = 1 To 10 '00
sinTemp = sinTemp / i
sinSum = sinSum + sinTemp
Next i
Print sinSum
添加新評論