Consider the seven positive integers: 123, 1234, 12345, 123456, 1234567, 12345678 and 123456789.
How many of these seven numbers are expressible as the difference of cubes of two positive integers?
1 none 2 8
12 none 20 27
123 none 339 343
1234 none 9234 9261
12345 none 274489 274625
123456 none 8488883 8489664
1234567 263374721 264609288 641 642
12345678 none 8365416067 8365427000
123456789 none 264114980164 264114999296
Only 1234567 fits the criterion, as 264609288 - 263374721 or 642^3 - 641^3.
s$ = "123456789"
For sz = 1 To 9
n = Val(Left(s, sz))
Text1.Text = Text1.Text & n
cr1 = 1
good = 0
Do
c1 = cr1 * cr1 * cr1
c2 = (cr1 + 1) * (cr1 + 1) * (cr1 + 1)
trial = c1 + n
crt = Int(trial ^ (1 / 3) + 0.5)
If crt * crt * crt = trial Then good = 1: Exit Do
cr1 = cr1 + 1
Loop Until trial < c2
If good Then
Text1.Text = Text1.Text & Str(c1) & Str(trial) & " "
Text1.Text = Text1.Text & cr1 & Str(crt) & crlf
Else
Text1.Text = Text1.Text & " none" & Str(trial) & Str(c2) & crlf
End If
Next sz
|
Posted by Charlie
on 2014-12-12 17:48:48 |