List all perfect square numbers over 1000, employing only 2 different decimal digits.
Example: 88^2=7744 will be on your list.
Ignore trivial solutions like 1 or 4 or 9 followed by an even number of zeroes.
How far can you go?
Known largest solution is
a 10-digit number 6,661,661,161.
square square root
16 4
25 5
36 6
49 7
64 8
81 9
121 11
144 12
225 15
441 21
484 22
676 26
1444 38
7744 88
11881 109
29929 173
44944 212
55225 235
69696 264
9696996 3114
6661661161 81619
Those above 1000 in bold face.
Numbers tested through squares of 10,000,000.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For i = 2 To 10000000
c$ = LTrim(Str(i * i))
ReDim had(9)
ct = 0
good = 1
For j = 1 To Len(c)
If had(Val(Mid(c, j, 1))) = 0 Then ct = ct + 1
If ct > 2 Then good = 0: Exit For
had(Val(Mid(c, j, 1))) = had(Val(Mid(c, j, 1))) + 1
Next
If good Then
good = 0
For j = 2 To Len(c)
If Mid(c, j, 1) <> "0" Then good = 1: Exit For
Next
If Len(c) Mod 2 = 0 Then good = 1
If good Then Text1.Text = Text1.Text & c & " " & i & crlf
End If
DoEvents
Next
Text1.Text = Text1.Text & crlf & tot & " done"
End Sub
|
Posted by Charlie
on 2018-10-21 19:41:09 |