南泽宇野能养多大:电话号码是七位数,它恰好是几个连续质数的乘积,这个积的末四位数是前三位数的10倍,电话号码是多少?

来源:百度文库 编辑:高考问答 时间:2024/04/28 21:18:03
电话号码是七位数,它恰好是几个连续质数的乘积,这个积的末四位数是前三位数的10倍,问:电话号码是多少?

Private Function IsPrimeNum(ByVal num)
Dim i As Integer
Dim Counter As Integer
If Not (num <= 1) Then
For i = 1 To num
If num Mod i = 0 Then Counter = Counter + 1
Next
If Counter = 2 Then
IsPrimeNum = True
Else
IsPrimeNum = False
End If
Else
IsPrimeNum = False
End If
End Function
Private Function CheckTelNum(ByVal num As Integer)
Dim StartNum As Integer
Dim EndNum As Integer
Dim TelNum As String
TelNum = CStr(num)
StartNum = CInt(Mid(TelNum, 1, 3))
EndNum = CInt(Mid(TelNum, 4, 4))
If StartNum * 10 = EndNum Then
CheckTelNum = True
Else
CheckTelNum = False
End If
End Function
Private Sub TelNum()
Dim TelNum As String
Dim PrimeNums As System.Collections.ArrayList = New System.Collections.ArrayList
Dim Result As Integer
Dim i As Integer
Dim j As Integer
Do While 1 = 1
i = i + 1
If IsPrimeNum(i) = True Then
PrimeNums.Add(i)
If Result = 0 Then
Result = i
Else
Result = Result * i
End If
If Len(CStr(Result)) = 7 Then
If CheckTelNum(Result) = True Then
MsgBox(CStr(Result))
For j = 1 To PrimeNums.Count
MsgBox(PrimeNums.Item(j))
Next
Exit Do
End If
End If
End If
Loop
End Sub

9699690
=2*3*5*7*11*13*17*19

9699690=2*3*5*7*11*13*17*19

9699690=2*3*5*7*11*13*17*19

9699690