List all the integers containing only prime-digits such that their squares also contain prime-digits only.
Hint: The highest qualifying number is below 77777.
Source: Claudio Meller's site.
Checked up to 30 million anyway; indeed all found are below 77777.
Each number is shown with its square:
5 25
235 55225
72335 5232352225
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
For n = 2 To 30000000
n2 = n * n
tst$ = LTrim(Str(n)) + LTrim(Str(n2))
good = 1
For i = 1 To Len(tst)
If InStr("2357", Mid(tst, i, 1)) = 0 Then good = 0: Exit For
Next
If good Then Text1.Text = Text1.Text & n & Str(n2) & crlf
DoEvents
Next
Text1.Text = Text1.Text & "done"
End Sub
|
Posted by Charlie
on 2019-01-31 15:57:31 |