10000以内能同时整除3和5和7的数之和..
写代码就可以了.
10000以内能同时整除3和5和7的数之和..
写代码就可以了.
Private Sub Command1_Click()
For i = 7 To 10000
If i Mod 3 = 0 And i Mod 5 = 0 And i Mod 7 = 0 Then H1 = H1 + i
Next
Text1.Text = H1
End Sub
Private Sub Command1_Click()
Dim Divisor as Integer '定义公约数
Dim i as Integer ‘计数值
Dim sum as Integer '结果值
Divisor = 3*5*7 '3,5,7的公约数
For i = 1 to Fix(10000/Divisor) '获得满足条件的数值个数
sum = sum + Divisor*i
DoEvents
Next
messagebox("和为:" + sum)
End Sub
Private Sub Command1_Click()
dim h as long
dim i as integer
For i = 7 To 10000 If i Mod 3 = 0 And i Mod 5 = 0 And i Mod 7 = 0 Then
h=h+i
end if
doevents
Next messagebox("满足条件的数的总和为"+cstr(h)) End Sub