Ramanujan–Nagell Conjecture


Ramanujan-Nagell Equation is an example of the exponential Diophantine equation. The diophantine equation is a polynomial equation with integer coefficients of two or more unknowns. Only integral solutions are required for the Diophantine equation.

Ramanujan-Nagell Equation is an equation between a square number and a number that is seven less than the power of 2, where the power of 2 can only be a natural number.

Ramanujan conjectured that the diophantine equation 2y - 7 = x2 has positive integral solutions and was later proved by Nagell.

$$\mathrm{2y−7=x^2\:has\:x\epsilon\:Z_+:x=1, 3, 5, 11, 181}$$

Triangular Number − It counts objects arranged in an equilateral triangle. A nth triangular number is the number of objects in a triangle with each side arranged with n objects. Thus, the 3rd Triangular number is the total number of objects in a triangle with each side having 3 objects = 6.

The formula for triangular number,

$$\mathrm{T_n=\displaystyle\sum\limits_{k=1}^n \:k=1 + 2 + 3 + ⋅⋅⋅ +𝑛 =\frac{n(n+1)}{2}=\left(\begin{array}{c}n+1\ 2\end{array}\right)where\:n\geq0}$$

The sequence of triangular numbers starting with 0th Triangular number,

0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153 …

Mersenne Number − It is a number that is one less than the power of 2.

The formula for the Mersenne number,

$$\mathrm{M_m=2^m−1\:where\:m\geq0}$$

Problem Statement

The problem is to find all the Ramanujan-Nagell numbers i.e. all the positive integer solutions to $\mathrm{2^m−1=\frac{n(n+1)}{2}}$ and the natural numbers satisfying the Ramanujan-Nagell equation i.e.2y7=x2

Sample Example

Input: x = 1, 3, 5, 11, 181
Expected Output: (0, 1, 3, 15, 4095), (3, 4, 5, 7, 15)

Solution

Starting with the equation,

$\mathrm{2^m−1=\frac{n(n+1)}{2}}$ ….(1)

Clearing the denominator of (1)

$\mathrm{2^{m+1}−2=n^2+n}$ ….(2)

For completing the square on the right-hand side of equation (2), multiply both sides by 4

$\mathrm{2^{m+3}−8=4n^2+4n}$ ….(3)

Further simplifying equation (3)

$\mathrm{2^m+3−7=(2n+1)^2}$ ….(4)

Equation (4) is in the form of Ramanujan-Nagell Equation i.e.$\mathrm{2^y−7=x^2}$.

According to the Ramanujan-Nagell Equation, x can take positive integer values of 1, 3, 5, 11, 181 only.

Thus, in equation (4), 2n + 1 can take the values of x = 1, 3, 5, 11, 181. On solving 2n + 1 with all the possible values of x, we get

$\mathrm{\Rightarrow𝑛 = 0, 1, 2, 5, 90}$

Then eventually, the Mersenne numbers which satisfy $\mathrm{2^m−1=\frac{n(n+1)}{2}}$ can also be calculated using the values of n.

When $\mathrm{n = 0,2^m− 1 = 0}$

$\mathrm{n = 1,2^m − 1 = 1}$

$\mathrm{n = 2,2^m − 1 = 3}$

$\mathrm{n = 5, 2^m − 1 = 15}$

$\mathrm{n = 90,2^m − 1 = 4095}$

Thus, {0, 1, 3, 15, 4095} are the Triangular Mersenne or Ramanujan-Nagell numbers.

Having the value of x in,$\mathrm{2^y−7=x^2}$ , we can find y by the following formula,

$$\mathrm{y=log_2(x^2+7)}$$

For x = 1, y = 3

For x = 3, y = 4

For x = 5, y = 5

For x = 11, y = 7

For x = 181, y = 15

Pseudocode

procedure rNagell (x[])
   ans[]
   for i = 0 to 4
      temp = (x[i] - 1) / 2
      ans[i] = (temp^2 + temp) / 2
end procedure

procedure rNagellNatural (x[])
   ans[]
   for i = 0 to 4
      temp = log2 (x[i]^2 + 7)
      ans[i] = temp
end procedure

Example: C++ Implementation

In the following program, we use the computations done in the above section to find the Triangular Mersenne numbers and natural numbers satisfying Ramanujan-Nagell Equation.

#include <bits/stdc++.h>
using namespace std;

// Functio for finding Triangular Mersenne or Ramanujan-nagell numbers
vector<int> rNagell(int x[]){
   vector<int> ans;
   for (int i = 0; i < 5; i++){
      // Applying the formula from the section above i.e. 2n-1 = x
      // 2^m - 1 = n(n+1)/2
      int temp = (x[i] - 1) / 2;
      ans.push_back((temp * temp + temp) / 2);
   }
   return ans;
}
// Function for finding natural numbers in Rmanujan-Nagell Equation i.e. 2^y - 7 = x^2
vector<int> rNagellNatural(int x[]){
   vector<int> ans;
   // y can be found as log2(x^2 + 7)
   for (int i = 0; i < 5; i++){
      int temp = (x[i] * x[i]) + 7;
      ans.push_back(log2(temp));
   }
   return ans;
}
int main(){
   int x[5] = {1, 3, 5, 11, 181};
   cout << "Triangular Mersenne Numbers = ";
   vector<int> triM = rNagell(x);
   for (int i = 0; i < 5; i++){
      cout << triM[i] << "  ";
   }
   cout << "\nNatural numbers sstisfying Ramanujan-Nagell Equation = ";
   vector<int> num = rNagellNatural(x);
   for (int i = 0; i < 5; i++){
      cout << num[i] << "  ";
   }
   return 0;
}

Output

Triangular Mersenne Numbers = 0  1  3  15  4095  
Natural numbers sstisfying Ramanujan-Nagell Equation = 3  4  5  7  15  

Conclusion

In conclusion, Triangular Mersenne numbers can be found by modulation the equation in the formof diophantine Ramanujan-Nagell equation and comparing with the values of x in the equation. The solution can be found with constant time complexity using the mathematical formulation.

Updated on: 25-Jul-2023

80 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements