同为数学爱好者,给你一个稍简单的代码:' suppose the five num is a,b,c,d,e. As a-b=c , c/d=e,e>=10 and d>=2,we can know that c>=20. As b>=10,we know that a>=30 Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer, e As Integer For a = 30 To 99 For b = 10 To a - 20 ' because a-b>=20 c = a - b For e = 10 To 45 ' because d*e<100 and d>=2 If c Mod e = 0 Then If isrepeat(a, b, c, c / e, e) = False Then Debug.Print a & "-" & b & "=" & c & vbTab & c & "/" & c / e & "=" & e End If End If Next Next Next End SubFunction isrepeat(ParamArray a()) As Boolean Dim temp As String, i As Integer, num As String isrepeat = FASLE temp = Join(a, "") For i = 1 To Len(temp) num = Mid(temp, i, 1) If UBound(Split(temp, num)) > 1 Then isrepeat = True: Exit Function Next End Function
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, e As Integer
For a = 30 To 99
For b = 10 To a - 20 ' because a-b>=20
c = a - b
For e = 10 To 45 ' because d*e<100 and d>=2
If c Mod e = 0 Then
If isrepeat(a, b, c, c / e, e) = False Then
Debug.Print a & "-" & b & "=" & c & vbTab & c & "/" & c / e & "=" & e
End If
End If
Next
Next
Next
End SubFunction isrepeat(ParamArray a()) As Boolean
Dim temp As String, i As Integer, num As String
isrepeat = FASLE
temp = Join(a, "")
For i = 1 To Len(temp)
num = Mid(temp, i, 1)
If UBound(Split(temp, num)) > 1 Then isrepeat = True: Exit Function
Next
End Function