Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Experts,

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

Thanks!

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

Thanks!

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial0 +1 = 1 = 1*1

Since you didn't say

N-1 and N+1 are a square and a cube, respectivelythe above works non-respectively.

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
```

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.)

Nah, someone asked me this in passing and you guys are way smarter than I ;)

I'm well out of school.

I'm well out of school.

Essentially, you are saying that if sqrt(x^3 - 2) is an integer, then x = 3.

Hmm....

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.

>> 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.

If the OP had included a comment "for the first quadrillion positive integers", then your extended computer solution would be adequate.

Math / Science

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

26+1 = 27 = 3*3*3