# When is $991n^2 +1$ a perfect square?

What should be the value of $n$ so that the number obtained after adding $1$ to $991$ times its square is itself a perfect square? Can you please give me a few hints on this topic with a few specific reasons?

## migrated from mathematica.stackexchange.comFeb 26 '16 at 21:38

This question came from our site for users of Wolfram Mathematica.

• when n=12055735790331359447442538767 – Jason B. Feb 26 '16 at 12:04
• Is this about the software Mathematica or math in general? At the moment, I would vote for migration to math.SE, unless you provide specific Mathematica context. – Yves Klett Feb 26 '16 at 12:07
• also when n=1008181262620735744167792492163533642911135470182537538260111475016204176230983865302765679861027454092581309875511466063617515681981450574077777701066673093443597760980859827958195535968873238692485090651626582411263121110856835646287364490934750153148422986688525426434604991928802125512669893600 Using the code FindInstance[991 n^2 + 1 == m^2 && m > 0 && n > 0, {m, n}, Integers, 2] – PlatoManiac Feb 26 '16 at 12:10
• You can see the first solution in oeis.org/A154651 and also when $991n^2+1$ is a prime. – Enrique Pérez Herrero Feb 26 '16 at 19:26
• Community moderators: if this was a bad migration please let me know. – Mr.Wizard Feb 26 '16 at 21:39

You can just use Reduce or Solve to find all solutions.

res = n /. Solve[991 n^2 + 1 - m^2 == 0 && n > 0 && m > 0, {n, m}, Integers]

{
ConditionalExpression[
-(((379516400906811930638014896080 - 12055735790331359447442538767 Sqrt[991])^C[1] -
(379516400906811930638014896080 + 12055735790331359447442538767 Sqrt[991])^C[1])/(2 Sqrt[991])),
C[1] \[Element] Integers && C[1] >= 1]
}


You can extract the first few solutions too

Join @@ Expand[Table[res /. C[1] -> c, {c, 1, 5}]]

{
12055735790331359447442538767,
9150698914859994783783151874415159820056535806397752666720,
6945680635899069348063079893854789105557565351617874814495165631493551941446359906376433,
5271999433569103258723914248134175943728525822653760579284456787639484415276520819628700849418208095077650461959498560,
4001620501221794409312976029031442933498062372893574314883667652582151036043020918794933123007401495529956942619504146458469286535007087494712913167
}


Here's a nice site that show's you how to solve quadratic bivariate diophantine equations:

https://www.alpertron.com.ar/QUAD.HTM (Though there does seem to be a hand wavy step at that site for your example.)

Also, note that your equation is an instance of Pell's equation, which is one of the most well known diophantine equations. The wiki link explains how to solve them pretty in depth.

To find all solutions within a range for n

{Reduce[{991 n^2 + 1 == m^2, 0 < n < 10^100, m > 0}, {n, m}, Integers] //
ToRules}

(*  {{n -> 12055735790331359447442538767,
m -> 379516400906811930638014896080}, {n ->
9150698914859994783783151874415159820056535806397752666720,
m -> 288065397114519999215772221121510725946342952839946398732799}, {n ->
694568063589906934806307989385478910555756535161787481449516563149355194144\
6359906376433,
m -> 21865108547738831347559404499351403341371834338816401962797676457811460\
9092763357330159760}}  *)

Length[%]

(*  3  *)


You want to solve $991n^2 +1=m^2$. Write it as $m^2-991n^2=1$ and this is Pell's equation.

This applet tells us that $$m=379516400906811930638014896080, n=12055735790331359447442538767$$ is the smallest solution.

Pell's equation $x^2-dy^2=1$ is famous for having very large smallest solutions even for small $d$.

• – lhf Feb 27 '16 at 12:24

I am giving you the following equations for which 991n^2+1=m^2 and they are these : (a)12055735790331359447442538767^2=145340765446276487999885076246978166471414204258297880289,now 145340765446276487999885076246978166471414204258297880289*991= 144032698557259999607886110560755362973171476419973199366399 whose successor 144032698557259999607886110560755362973171476419973199366400 is a perfect square and its square root is 379516400906811930638014896080, (b)9150698914859994783783151874415159820056535806397752666720^2=83735290630419886064759896365549964843256299345531716534246061798413453014599018855005034552161536336522871395558400,now 83735290630419886064759896365549964843256299345531716534246061798413453014599018855005034552161536336522871395558400*991=82981673014746107090177057298260015159666992651421931085437847242227731937467627685309989241192082509494165552998374400 whose successor 8298167301474610709017705729826001515966699265142193108543784724222773 1937467627685309989241192082509494165552998374401 is a perfect square and its square root is 288065397114519999215772221121510725946342952839946398732799 (c)6945680635899069348063079893854789105557565351617874814495165631493551941446359906376433^2=48242479495903300346535943247036699887044153049589496412442463635213227162518389751116306437221217883259804828582401030720561122083475138010369817501016733633284033132297803489,now 4824247949590330034653594324703669988704415304958949641244246363521322 7162518389751116306437221217883259804828582401030720561122083475138010 369817501016733633284033132297803489*991=47808297180440170643417119757813369588060755672143190944730481462496308118055724243356259679286226922310466585125159421444076071984723861768276489143507583030584476834107123257599 whose successor 4780829718044017064341711975781336958806075567214319094473048146249630 8118055724243356259679286226922310466585125159421444076071984723861768 276489143507583030584476834107123257600 is a perfect square and its square root is 2186510854773883134755940449935140334137183433881640196279767645781146 09092763357330159760,I have found these three solutions of n & m through research,

• @Community-Please donot delete my answer as this is the result of my research on Wolfram Mathematica – user324148 Mar 19 '16 at 3:59