I added two three-digit numbers a and b, where the six digits I
used to write a and b were all different. a + b was another three-digit number.
I added the digits in a and b to obtain another number n.
What can you say about n?
DefDbl A-Z
Dim had(60), crlf$
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
For a1 = 1 To 9
astr$ = LTrim(Str(a1))
For a2 = 0 To 9
a2str$ = LTrim(Str(a2))
If InStr(astr, a2str) = 0 Then
astr = astr + a2str
For a3 = 0 To 9
a3str$ = LTrim(Str(a3))
If InStr(astr, a3str) = 0 Then
astr = astr + a3str
For b1 = 1 To 9
b1str$ = LTrim(Str(b1))
If InStr(astr, b1str) = 0 Then
bstr$ = b1str
For b2 = 0 To 9
b2str$ = LTrim(Str(b2))
If InStr(astr + bstr, b2str) = 0 Then
bstr = bstr + b2str
For b3 = 0 To 9
b3str$ = LTrim(Str(b3))
If InStr(astr + bstr, b3str) = 0 Then
bstr = bstr + b3str
If Val(astr) + Val(bstr) <= 999 Then
tot = 0: ab$ = astr + bstr
For i = 1 To 6
tot = tot + Val(Mid(ab, i, 1))
Next
had(tot) = 1
End If
DoEvents
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
Next
For i = 1 To 60
If had(i) Then Text1.Text = Text1.Text & Str(i)
Next
Text1.Text = Text1.Text & crlf & " done"
DoEvents
End Sub
Finds that n must be 15, 16, 17 or 18.
|
Posted by Charlie
on 2019-08-03 13:01:15 |