All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Quite a pair! (Posted on 2018-01-26)
The numbers A & B:
1. Comprise 5 distinct digits each.
2. Jointly use all 10 digits.
3. None has a leading zero.
4. Both A^2 and B^2 are 10-pandigital numbers.

Find the values of A and B.

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 2
`  A    B           A^2        B^235172 60984     1237069584 371904825657321 60984     3285697041 371904825658413 96702     3412078569 935127680459403 76182     3528716409 5803697124`

A and B can of course be switched.

DefDbl A-Z
Dim crlf\$, validnum(1000) As String, validnums

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For a = 1 To 9
For b = 0 To 9
If b <> a Then
For c = 0 To 9
If c <> a And c <> b Then
For d = 0 To 9
If d <> a And d <> b And d <> c Then
For e = 0 To 9
If e <> a And e <> b And e <> c And e <> d Then
n = 10000 * a + 1000 * b + 100 * c + 10 * d + e
nsq = n * n
s\$ = LTrim(Str(nsq))
If Len(s) = 10 Then
good = 1
For i = 2 To 10
If InStr(s, Mid(s, i, 1)) < i Then good = 0: Exit For
Next
If good Then
validnums = validnums + 1
validnum(validnums) = n
End If
DoEvents
End If
End If
Next e
End If
Next d
End If
Next c
End If
Next b
Next a

For i = 1 To validnums - 1
For j = i + 1 To validnums
concat\$ = validnum(i) + validnum(j)
good = 1
For k = 2 To 10
If InStr(concat, Mid(concat, k, 1)) < k Then good = 0: Exit For
Next
If good Then
Text1.Text = Text1.Text & validnum(i) & " " & validnum(j) & "     "
Text1.Text = Text1.Text & validnum(i) ^ 2 & " " & validnum(j) ^ 2 & crlf
End If
Next
Next

Text1.Text = Text1.Text & crlf & validnums & " done"

End Sub

 Posted by Charlie on 2018-01-26 14:13:29

 Search: Search body:
Forums (0)