根据公式e=1+1/1!+1/2!+1/3!+...,求e的近似值,精度要求为10-6.
问题描述:
根据公式e=1+1/1!+1/2!+1/3!+...,求e的近似值,精度要求为10-6.
vc++
答
Option ExplicitPrivate Sub Command1_Click()Dim e0 As Double,e1 As Double,k As Integere0 = 0:e1 = 1:k = 1While e1 - e0 > 0.000001e0 = e1e1 = e1 + GetResult(k)k = k + 1WendPrint e1End SubFunction GetRes...