N is an integer below 10,000.
N's square is a concatenation of two consecutive numbers.
Find all possible values of N.
For n = 1 To 10000
n2 = n * n
tst$ = LTrim(Str(n2))
halfway = Int(Len(tst) / 2)
p1 = Val(Left(tst, halfway))
p2 = Val(Mid(tst, halfway + 1))
If p2 = p1 + 1 Then
Text1.Text = Text1.Text & n & " " & n2 & crlf
End If
Next
produces
1 1
155 24025
274 75076
428 183184
573 328329
727 528529
846 715716
2191 4800481
7810 60996100
where the first line is obviously spurious, due to a null length string representing zero as the integer prior to 1. But of course if we concatenate 01, it is 1^2.
Also spurious are 155, 274 and 2191 as they each require a leading zero to be attached to the second of the two consecutive numbers.
That leaves 428, 573, 727, 846 and 7810.

Posted by Charlie
on 20190521 16:17:35 