Dim i, j As Integer
Dim je, sum As Double
sum = 0
For j = 1 To 20
je = 1
For i = 1 To j
je = je * i
Next i
sum = sum + je
Next j
TextBox1.Text = CStr(sum)
vb程序1!+……20!的值
答案:2 悬赏:60 手机版
解决时间 2021-12-20 08:15
- 提问者网友:我们很暧昧
- 2021-12-19 22:16
最佳答案
- 五星知识达人网友:玩家
- 2021-12-19 23:54
2.56132749411182e+18
全部回答
- 1楼网友:行路难
- 2021-12-20 01:11
楼上一堆人都不知道精度是会溢出的吗? 你们自己算算20!都多少位了?10!是7位,20!不会低于18位,哪个精度也表示不了这么大数字的精确值,只能用高精度计算。 '高精度乘法 sub multiply(src() as integer, multiplier as integer) dim i as integer for i = 0 to ubound(src) if src(i) <> 0 then src(i) = src(i) * multiplier end if next carryout src end sub '高精度加法 sub add(src() as integer, adder() as integer) dim i as integer for i = 0 to ubound(src) if i <= ubound(adder) then src(i) = src(i) + adder(i) end if next carryout src end sub '高精度进位 sub carryout(src() as integer) dim i as integer for i = 0 to ubound(src) if src(i) > 9 then if i = ubound(src) then redim preserve src(i + 1) end if src(i + 1) = src(i + 1) + src(i) \ 10 src(i) = src(i) mod 10 end if next end sub '主程序 sub main() dim i as integer dim mdigit() as integer dim sum() as integer redim sum(0), mdigit(0) sum(0) = 0: mdigit(0) = 1 for i = 1 to 20 multiply mdigit, i if ubound(mdigit) > ubound(sum) then redim preserve sum(ubound(mdigit)) end if add sum, mdigit next dim result as string for i = ubound(sum) to 0 step -1 result = result & sum(i) next msgbox result end sub 最后结果是:2561327494
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯