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

 Find From First and Last (Posted on 2016-02-02)
N is a perfect square whose first four digits are 2016 and the last four digits are also 2016.

Determine the four smallest values of N.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution Comment 1 of 1
`        N                   sqrt(N)   201604592016              449004 20169045072016             4490996201611714592016            14199004201668287392016            14200996201682715862016            14201504`

In fact by stretching VB's precision to its limits we get:

2.01609944179202E+15            44900996
2.01614506146202E+15            44901504
2.01632395302202E+15            44903496
2.01636957523202E+15            44904004
2.01654847675202E+15            44905996
2.01659410150202E+15            44906504
2.01677301298202E+15            44908496
2.01681864027202E+15            44909004
2.01699756171202E+15            44910996

Though the output has switched to a rounded scientific form, the last digits of the square roots verify the exactness of the results.

DefDbl A-Z
Dim crlf\$

Form1.Visible = True

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

pwr10 = 100000
Do
low = -Int(-Sqr(2016 * pwr10))  ' ceiling
high = Int(Sqr(2017 * pwr10))   ' floor
For sr = low To high
DoEvents
sq = sr * sr
sqred = Int(sq / 10000)
sqmod = sq - 10000 * sqred  ' workaround for type limitation on mod function
If sqmod = 2016 Then
Text1.Text = Text1.Text & sq & "            " & sr & crlf
End If
Next
pwr10 = pwr10 * 10
Loop Until pwr10 > 100000000000#

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

End Sub

 Posted by Charlie on 2016-02-02 11:27:00

 Search: Search body:
Forums (0)