I believe that some information about a natural number's primality can be found from the continued fraction representation of its square root. *The origin of this hypothesis stems from studying the Ulam and Sacks number spirals, most evidently from the later. The Sacks spiral essentially plots a spiral by using theta = sqrt(n)*2pi and r = sqrt(n), although I've found that using r = n produces better looking results. If you plot out just the prime numbers using this method, Fibonacci style spirals appear throughout the system.

This leads to continued fraction representations of the square roots of natural numbers. Continued fractions can also be treated as recurrence relations, like the Fibonacci series, which is how I got to this point. The root of any non-square natural number has been proven to be irrational, while the root's continued fraction representations have also been proven to be periodic and palindromic. By including*the natural integer portion of the root along with the set of coefficients of a single period of the continued fraction of the root, we can get a sort of fingerprint of the number. This fingerprint is unique and deterministic.

Anyways, my conjecture is that for the continued fraction representation of the square root of a natural number N, if the number of terms in its period, add one to include the integer root, is odd, then the middle term must be the root of the nearest odd square which is not greater than N in order for N to be prime. I've run this test programatically well into the billions and trillions, and although false positives exist, I have yet to find a false negative case.

For example,19 is prime and the middle term 3 is equals to the root of the nearest odd square not greater than 19.
√19 [ 4; 2, 1, 3, 1, 2, 8]

However,27 is an early false positive. Even though the middle term 5*is the root of the nearlest odd square, this number is not prime.
√27 [ 5; 5, 10]

And welcome to the forum. I find this fascinating, but unfortunately I am not a mathematician nor (especially!) a number theory expert so I have no knowledge of any previous work on this subject. However, I have some experience with continued fraction expansion calculations, so I might be able to write some programs to check your work, if you would like me to (up to a point of course, I'm not sure about checking up to trillions. And don't worry, I won't take any credit for your work).

If I were to write these programs, I would probably use GMP on Linux or MPIR on Windows. Did you use similar software? What was your check for primality?

Also, does your analysis show that if the number of terms is even, the last term is equal to twice the first term as the following samples (and others) show?

You may have to repeatedly hit "more terms" as I can't seem to get the view with all terms to show automatically.

Also, I have no idea how common or uncommon this property (last entry is double the first entry) is for non-prime number square roots. I will let you research that if you are so inclined (another reason that I will take no credit).

Last edited by jks; May 23rd, 2016 at 07:11 PM.
Reason: Added links for GMP and MPIR.

I wrote my test code in Java, since I'm very familiar with that language. Just to be sure, I'm using pretty standard brute force divisibility checking up to the root of the testing number. I've let it run into the hundreds of billions with out a contradictory case!

Have you researched to see if there is any literature out there that specifically states the conjecture (other that what you have presented here)?

Edit:
Also, the primes that you find that have the middle term you are looking for, are they of the form $4n+3$ as in OEIS A002145. A very quick check of the patterns of square roots from 1-99 as given in the link you provided seems to indicate it.

Last edited by jks; May 25th, 2016 at 11:06 PM.
Reason: Added the OEIS question.

I haven't found any reference to this anywhere else, so far. As for the 4n+3 series, I noticed this about a month ago, but I was checking as (n % 4) = 3. The 4n+3 primes do seem to pass this conjecture, but there are other odd CFE termed primes that are not 4n+3. The over lap is certainly interesting, though!

I wrote a program (actually some programs) and I checked up to 100 million and I found no violations of your conjecture. I am currently running up to 1 billion and expect it to finish tomorrow. I will post the results.

A run to 1 million took 4s, to 10 million took 83s, and to 100 million took 2029s. So I expect the 1 billion run to take about 60000s. This will be my last run, it is all yours after that, but at least your results have been verified up to 100 million (and hopefully a billion, tomorrow).

Quote:

The 4n+3 primes line up with the conjecture!

Good, because I haven't found any that weren't $4n+3$ up to 100 million. I will hopefully have an update on this tomorrow up to 1 billion.

FYI, the program that I am running is written in C, and it uses the 'mpz_nextprime' function of MPIR (2.5.1) to get primes. Up to 100 million, it only mis-reported 18_790_021 as prime*, which it is not. The function uses statistical methods combined with Miller-Rabin tests (I think) to check for composites but sometimes composites pass through as primes.

So 18_790_021 failed the middle CFE value test (and the $4n+3$ test) but a check here showed that it was composite. I assume that I will have to check some more numbers during the 1 billion run.

If anyone is interested, I will post the code.

*Other composite numbers may have been passed through as well, but if they were, the root CFE had an even number of terms (whole number plus repeating cycle, as you defined it), in which case no checks would have been made.

The 1 billion run has completed and the 'middle coefficient' property described above was confirmed. It was also confirmed that all of the primes were of the form $4n+3$.

Unfortunately, the way the program was structured, it did not check if other $4n+3$ primes had an even number of coefficients. So I re-structured the program to check that if the prime is of the $4n+3$ form, it also has the 'middle coefficient' property.

The run to 100 million is complete and so far all, and only, the $4n+3$ primes have this property. The 1 billion run is in progress.