Will there be infinity prime numbers of the sort $a^2 -2$ (where $a$ is odd)?

To begin with, every odd composite number can be written as $a^2$ or as $a_{x}^2 -a_{y}^2$ as long as either $x$ or $y$ is odd and the other is even, and the difference between $x$ and $y$ is bigger than or equal to $3$ (and odd).


$a_5^2-a_2^2=5^2 - 2^2 = 21$

$a_7^2-a_4^2=7^2 - 4^2 = 33$

$a_9^2-a_4^2=9^2 - 4^2 = 65$

$a_9^2-a_2^2=9^2 - 2^2 = 77$

. . .

This let me automatically think that there is a better chance to find prime numbers at :

$a^2-p$ where $p$ is a prime number (or semi prime). Because the chances that $a^2-p$ can be rewritten as $a_{x}^2 -a_{y}^2$ (where the difference between ($x$ and $y$) ≥ 3, and either one is odd and the other even) must be low.

The quickest way to conduct my research was to set up a php script and see the results for $a^2-2$ where $a$ is an odd number:

Running the script all the way to $a=100,001$: I have noticed that there will (so far) always be a results that is a prime number, but the other thing that I have noticed is that when the results are composite, they will have prime factors that appear twice (randomly to my knowledge) and then continue appearing + $2$ times that prime factor:

The first examples are for prime factor $7$:

$a_{11}^2 -2 =119$ (prime factors are $7$ and $17$)

$a_{17}^2 -2 =287$ (prime factors are $7$ and $41$)


$a_{25}^2 -2 =623$ (prime factors are $7$ and $89$)

$a_{31}^2 -2 =959$ (prime factors are $7$ and $137$)

. . .

As I analyzed the results, I have noticed that if the result is indeed a composite, some prime factors appear, while others never do.

For the experiment of $a^2-2$ where $a$ is an odd number, when the result was a composite, I had the following prime factors appear:

$7, 17, 23, 31, 41, 47, 71 , 73, ...$

Never: $3,5,11,13,19,29,37,...$

That leads me to think that while the prime factors that appear twice are repeated, so many other prime factors don't appear at all, and therefor my intuition is indeed correct that there will be infinity prime numbers in the sort of $a^2-2$ (where $a$ is odd).

My questions are:

a) Why is it that some prime factors appear while others don't?

b) Why do these prime factors appear twice before repeating themselves based on their $2p$ value?

c) Is my intuition about having infinity prime numbers of the sort $a^2−2$ correct (where $a$ is odd), and is there a way to prove it?

  • $\begingroup$ What does “always” mean? 47 is prime. Done. $\endgroup$ Commented Feb 4 at 20:29
  • 6
    $\begingroup$ Are you asking: are there infinitely many primes of the form $n^2-2$? If so, while that would follow from standard conjectures, it is not known. No non-linear polynomial has been shown to take infinitely many prime values. Or were you asking something else? $\endgroup$
    – lulu
    Commented Feb 4 at 20:30
  • $\begingroup$ Yes i mean infinity more primes $\endgroup$ Commented Feb 4 at 20:31
  • 1
    $\begingroup$ So, the Bunyakovsky Conjecture would certainly imply what you want. But, as I mentioned, nobody knows. $\endgroup$
    – lulu
    Commented Feb 4 at 20:32
  • 3
    $\begingroup$ Just to address the other part of your question (why some primes appear as factors of numbers of the form $a^2-2$ and some don't), you're essentially asking about quadratic residues. In particular, if $2$ is not a quadratic residue modulo some prime $p$, then $p$ will never divide a number of that form. If it is, $p$ will divide $a^2-2$ for infinitely many $a$. $\endgroup$ Commented Feb 4 at 20:45

1 Answer 1


To address this part of your post:

You write:

I had the following prime factors appear: 7,17,23,31,41,47,71,73,...

Never: 3,5,11,13,19,29,37,...

Your primes that appear are the primes $\pm1$ (mod 8), while the ones that never appear yield a remainder of 3 or 5 when divided by 8.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .