Find number of ordered pairs ( m , n ) where m and n are positive integers such that m n − 1 n 3 + 1 is an integer.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Hey, I like this problem.
First note that if m n − 1 ∣ n 3 + 1 then m n − 1 ∣ m 3 n 3 − 1 + n 3 + 1 = n 3 ( m 3 + 1 ) It follows that m n − 1 ∣ m 3 + 1 because g cd ( m n − 1 , n 3 ) = 1 , so if ( m , n ) is an answer ( n , m ) will be too. If n = m we get m n − 1 n 3 + 1 = n 2 − 1 n 3 + 1 = n + n − 1 1 So n − 1 ∣ 1 and n = 2 . Therefore ( 2 , 2 ) is an answer and from now on we can suppose m > n . Let n = 1 , it gives m = 2 , 3 , we get four answers from here: ( 1 , 2 ) , ( 2 , 1 ) , ( 1 , 3 ) , ( 3 , 1 ) Note that if m n − 1 n 3 + 1 = r then r ≡ n − 1 , and r have the form of k n − 1 for some positive integer k . Since m > n k n − 1 = m n − 1 n 3 + 1 < n 2 − 1 n 3 + 1 = n + n − 1 1 k n − 1 < n + n − 1 1 k < 1 + n 1 + n ( n − 1 ) 1 ≤ 2 k < 2 Thus k = 1 and we have ( n − 1 ) ( m n − 1 ) = n 3 + 1 , hence n − 1 ∣ n 3 + 1 or n − 1 ∣ n 3 + 1 − ( n 3 − 1 ) = 2 n − 1 ∣ 2 As a result n = 2 or n = 3 which gives us 2 m − 1 = 9 or 2 ( 3 m − 1 ) = 2 8 and both of them leads to m = 5 , so we get four other answers from here: ( 2 , 5 ) , ( 5 , 2 ) , ( 3 , 5 ) , ( 5 , 3 ) .
I'm going to hazard a guess that there are no solutions where m or n is greater than 1 0 0 0 . Then this is actually very simply solved by checking all the ordered pairs ( m , n ) for positive integers m and n under 1000.
public class CubicSquareRatio
{
public static void main(String[] args)
{
for (double length = 5.0; length < 1000.0; length++)
{
int count = 0;
for (double m = 1; m < length; m++)
for (double n = 1; n < length; n++)
{
if (((n * n * n + 1.0)/(m * n - 1.0)) % 1.0 == 0.0)
count++;
}
System.out.println(count);
}
}
}
Indeed, it prints " 5 " for length = 5.0, and " 9 " for every length from 6.0 to 999.0. Unless there is some solution with m ≥ 1 0 0 0 or n ≥ 1 0 0 0 (in which case there would probably be infinitely many solutions), there are only the 9 solutions found.
Hi bro . Nice solution .
I tried copying your code in my Netbeans IDE 6.5.1 , it show that inner classes cannot have static declarations . Can you please help ?
Log in to reply
Very strange! Before we throw out the whole kitchen to fix the sink, have you taken some preliminary debugging steps?
If none of those help, you will have to be creative in debugging. I like using IDEs for fast programming, but if I can't resolve a debug issue immediately, I like to write with notepad++ and compile from the command line instead. IDEs can sometimes have specific problems. I am not familiar with netbeans, but it is possible that it creates the class on the fly so you don't have to write it out; if that's the case, simply removing the lines
public class CubicSquareRatio (delete)
{ (delete)
...
} (delete)
might work.
Log in to reply
I got the program to work :) But here's the output .
run: 5 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 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9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
How did you decide that the answer is 9 ? This is the last question that I have, plz answer it:)
Log in to reply
@Arpit Agarwal – Basically, the program finds the total number of solutions where m and n are both less than double length; The program has a main loop that increases length by 1 . 0 each time and finds the total number of solutions again. Every time it does this, it prints out the total number of solutions found.
When length = 5 . 0 , it has found 5 unique solutions. For every iteration after that, though, it has found 9 solutions. The program prints out almost 1 0 0 0 9 's, meaning if we check only the integers from 1 to 1 0 0 0 , we will only find 9 solutions, and it hasn't changed since we only checked the integers from 1 to 5 . Since the number of solutions hasn't changed for almost 1 0 0 0 new tries, I inferred that it will not change again, no matter how many more numbers we try.
To further illustrate the point, try starting length at 1 . 0 instead. I started at 5 . 0 in my program to save a bit of time.
for (double length = 1.0; length < 1000.0; length++)
{
...
}
It should print 0 0 3 5 5 9 9 9 9 9 . . . meaning there are 0 solutions where both m and n are less than 1 , 0 solutions where both m and n are less than 2 , 3 solutions where both m and n are less than 3 , 5 solutions where both m and n are less than 4 , 5 solutions where both m and n are less than 5 , and 9 solutions where m and n are less than any integer from 6 to 9 9 9 . This is why I inferred there are only 9 solutions.
Log in to reply
@Caleb Townsend – Thanks bro, the last part of your answer explained it all :) +1
Even after you hazard a guess, you should try and see if you can prove your guess.
Note that ( m , n ) is a solution iff
m 2 n 2 + m n + 1 + m n − 1 n 3 + 1 = m n − 1 n 3 ( m 3 + 1 )
is an integer. Since
g
c
d
(
n
,
m
n
−
1
)
=
1
, this occurs iff
m
n
−
1
m
3
+
1
is a solution. That is,
(
m
,
n
)
is a solution iff
(
n
,
m
)
is a solution. Suppose
(
m
,
n
)
is a solution and
m
n
>
1
;
defining
q
as in the current solution, we see that
q
<
n
. Further, since
(
n
2
−
1
)
2
≥
n
3
+
1
for
n
≥
2
, we see that
q
<
n
.
Similarly, if
m
=
n
>
2
, we get
q
<
n
.
Thus the following steps
( i ) If m < n , interchange m and n ,\
( i i ) If m > n > 1 or m = n > 2 , replace ( m , n ) by ( q , n ) ,
starting from any solution we can always reduce to a smaller solution untill we get to either m = n = 2 or n = 1 .
In the latter case we have m = 2 o r 3 . Backtracking gives the chain of solutions
( 3 , 5 ( → ( 5 , 3 ) → ( 1 , 3 ) → ( 3 , 1 ) , ( 2 , 5 ) → ( 5 , 2 ) → ( 1 , 2 ) → ( 2 , 1 ) and the single solution ( 2 , 2 ) .
Thus these 9 pairs are all solutions to the problem.
Answer: 9 .
Python
1 2 3 4 5 6 |
|
Problem Loading...
Note Loading...
Set Loading...
Suppose m n − 1 n 3 + 1 = k where k is a positive integer. Then n 3 + 1 = ( m n − 1 ) k and so it is clear that k ≡ − 1 ( m o d n ) . So, let k = j n − 1 where j is a positive integer. Then we have n 3 + 1 = ( m n − 1 ) ( j n − 1 ) = m j n 2 − ( m + j ) n + 1 which by cancelling out the 1s and dividing by n yields n 2 = m j n − ( m + j ) ⇒ n 2 − m j n + m + j = 0 . The equation x 2 − m j x + m + j = 0 is a quadratic. We are given that n is one of the roots. Let p be the other root. Notice that since n + p = m j we have that p is an integer, and so from n p = m + j we have that p is positive.
It is obvious that j = m = n = p = 2 is a solution. Now, if not, and j , m , n , p are all greater than 1 , we have the inequalities n p > n + p and m j > m + j which contradicts the equations n p = m + j , n + p = m j . Thus, at least one of j , m , n , p is equal to 1 .
If one of m , j is 1 , without loss of generality assume it is j . Then we have n p = m + 1 , n + p = m . That is, n p − n − p = 1 ⇒ ( n − 1 ) ( p − 1 ) = 2 which gives positive solutions ( n , p ) = ( 3 , 2 ) , ( 2 , 3 ) . These give m = 5 and since we assumed j = 1 , we can also have m = 1 and j = 5 .
If one of n , p is 1 , without loss of generality assume it is p . Then we have n = m + j , n + 1 = m j . That is, m j − m − j = 1 ⇒ ( m − 1 ) ( j − 1 ) = 2 which gives positive solutions ( m , j ) = ( 3 , 2 ) , ( 2 , 3 ) . These give n = 5 and since we assumed p = 1 , we can also have n = 1 and p = 5 .
From these, we have all solutions ( m , n ) = ( 2 , 2 ) , ( 5 , 3 ) , ( 5 , 2 ) , ( 1 , 3 ) , ( 1 , 2 ) , ( 3 , 5 ) , ( 2 , 5 ) , ( 3 , 1 ) , ( 2 , 1 ) . Hence we have a total of 9 ordered pairs.