求3到200之间所有非偶数且非素数的数之和,不知道哪里编错了Private Sub Command1_Click() s = 0 For a = 3 To 200 Step 2 For b = 2 To a - 1 If a Mod b = 0 Then s = s + aNext bNext aPrint send sub
问题描述:
求3到200之间所有非偶数且非素数的数之和,不知道哪里编错了
Private Sub Command1_Click()
s = 0
For a = 3 To 200 Step 2
For b = 2 To a - 1
If a Mod b = 0 Then s = s + a
Next b
Next a
Print s
end sub
答
Dim a As Integer,b As IntegerDim s As Integers = 0For a = 3 To 200 Step 2For b = 3 To a - 1If a Mod b = 0 Then s = s + aNext bNext aDebug.Print s这样写,会好一点