# Integer Question

Experts,

Can you tell me the only integer N, where N-1 and N+1 are a square and a cube?

Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
26 -1 = 25 = 5*5
26+1 = 27 = 3*3*3
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
No guarantee that is the only case though....
0
Commented:
0 - 1 = -1 = (-1)*(-1)*(-1)
0 +1 = 1 = 1*1

Since you didn't say
N-1 and N+1 are a square and a cube, respectively
the above works non-respectively.
0
If N-1 must be the square and N+1 must be the cube, seems like 26 is the only number that fits the bill. If it can be either, you'll have a lot more numbers.

If you want to find numbers higher than that, set your maximum in this VBA snippet and run to  your heart's content:

``````Option Explicit
Public Sub TestThis()
Dim ndx As Double
Dim s As Double
Dim c As Double

For ndx = 1 To 999999999
s = sqr(ndx - 1)
c = (ndx + 1) ^ (1 / 3)
If s = Round(s, 0) And c = Round(c, 0) Then
Debug.Print ndx
End If
DoEvents
Next ndx
End Sub
``````
If you want to check either/or, this code will give many more numbers.

``````Option Explicit
Public Sub TestThis()
Dim ndx As Double
Dim s1 As Double
Dim c1 As Double
Dim s2 As Double
Dim c2 As Double

For ndx = 0 To 999999999
If ndx > 0 Then
s1 = sqr(ndx - 1)
Else
s1 = 2
End If
c1 = (ndx + 1) * (ndx + 1) * (ndx + 1)
s2 = sqr(ndx + 1)
c2 = (ndx - 1) * (ndx - 1) * (ndx - 1)
If s1 = Round(s1, 0) And c1 = Round(c1, 0) Then
Debug.Print ndx
End If
If s2 = Round(s2, 0) And c2 = Round(c2, 0) Then
Debug.Print ndx
End If
DoEvents
Next ndx
End Sub
``````
0
Hope this wasn't a classroom homework assignment, else I'm telling your teacher. :)
0
Commented:
>> else I'm telling your teacher
Heh, maybe it was. Not sure what grade though given the questions that Marv1n has been asking over the years. (You can see what questions he asks by clicking on his name and go to the Activity tab, and then the Questions tab.)
0
Author Commented:
Nah, someone asked me this in passing and you guys are way smarter than I ;)

I'm well out of school.
0
Commented:
I'm curious how you would go about proving that 26 is the only one.
Essentially, you are saying that if sqrt(x^3 - 2) is an integer, then x = 3.
Hmm....
0
0
Commented:
The script would only prove it if it went from 1 to infinity, which it can't, you'd have issues with your double precision long before that.
0
Well DUH. Define the field type to allow larger values, and go far enough to satisfy that you are very unlikely to find a number in high exponential ranges where a distance of 2 will render a perfect square and cube. The script was for the thinking man. :)
0
Commented:
If you pick an integer purely at random, the odds that it will be small enough to fit in the RAM of any computer in existence today is statistically 0.

So the script demonstrates that it holds true for roughly 0% of the integers. That may be enough for some people, but not for me.
0
Enjoy your personal world. All the best.
0
Commented:
To deal with the OP question "the only integer", you need a mathematical proof that deals with all numbers, not just the first zillion numbers.

>> you are very unlikely to find a number in high exponential ranges where a distance of 2 will render a perfect square and cube.
It may be that your intuition is correct. Then again, you may be wrong. And even if correct, you are only claiming "unlikely" as opposed to "impossible". It may be hard or even impossible to prove or disprove mathematically the OP conjecture.

If I had time, I would at least start considering some known number rules such as:
the cube of integer can be written as the difference of two square or similarly,
for i=1..N sum(i^3) = (N+1)^2.