41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
Function isSubstring(kStr As String, f As Integer) As Integer
|
|
If InStr(kStr, Str(f)) > 0 Then
|
|
Return -1
|
|
End If
|
|
Return 0
|
|
End Function
|
|
|
|
|
|
Dim As Integer requiredNumbers = 20
|
|
Dim As Integer kCount = 0
|
|
For k As Integer = 11 To 99999999 Step 2
|
|
If k Mod 3 <> 0 And k Mod 5 <> 0 And k Mod 7 <> 0 Then
|
|
Dim As Integer isCandidate = -1
|
|
Dim As String kStr = Str(k)
|
|
Dim As Integer v = k
|
|
Dim As Integer fCount = 0
|
|
For f As Integer = 11 To Sqr(k) + 1
|
|
If v Mod f = 0 Then
|
|
isCandidate = isSubstring(kStr, f)
|
|
If isCandidate Then
|
|
While v Mod f = 0
|
|
fCount += 1
|
|
v \= f
|
|
Wend
|
|
Else
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next f
|
|
If isCandidate And (fCount > 1 Or (v <> k And v > 1)) Then
|
|
If v > 1 Then isCandidate = isSubstring(kStr, v)
|
|
If isCandidate Then
|
|
Print Using "#######,###"; k;
|
|
kCount += 1
|
|
If kCount Mod 10 = 0 Then Print
|
|
End If
|
|
End If
|
|
End If
|
|
If kCount >= requiredNumbers Then Exit For
|
|
Next k
|