用一个比一打但又尽可能小的自然数,乘以1997,使它的乘积中出现5个连续的“9”。
试着用vb编个小程序来算,下边是我的代码:
Dim i As Integer, x As Integer
Dim lngresult As Long
Dim strwant As String
i = 2
Do
lngresult = 1997 * i
For x = 1 To Len(CStr(lngresult))
strwant = Mid(CStr(lngresult), x, 5)
If strwant = "99999" Then
Exit For
Else: x = x + 1
End If
Next x
i = i + 1
Loop Until strwant = "99999"
Print i
出错显示上边红色的部分“溢出”
实在看不出哪里溢出了,所以来请教大家。