Simple primality test

109 Views Asked by At

I am an amateur and have been doing some number theory for fun, so I apologize if my post is absolutely trivial:)

I have been playing with primality tests and I thought of the following method: Pick a number that you want to test for primality, say 13.List all whole number addends of the number as pairs:

1 12

2 11

3 10

4 9

5 8

6 7

If all pairs are relatively prime (no number greater than 1 can be "factored out"), the number is prime.

This is all pretty simple but I wanted to know where is this mentioned in the literature and where one could go from here to improve the algorithm or expand on this simple idea.

Thank you!

1

There are 1 best solutions below

0
On

This is probably not mentioned in the literature, but you can prove it like this. Suppose that $n$ is your number and that $p$ is a prime dividing $n$. Let $q = n - p$, so that one line of your list will be $$ p + q = n.$$ As $p$ divides $p$ and $p$ divides $n$, we get that $p$ divides $q$. Thus a nontrivial divisor will lead to at least one line where all terms share a common factor.

More generally, if $a$ is any number that shares a nontrivial factor $p$ with $n$, and $a + b = n$, then $p$ must also divide $b$. From this point of view, to show a number is not prime in this method amounts to finding another number that shares a common factor with $n$. This is very similar to trial division --- just looking at all numbers less than $n$ for a common factor.

However you can give speedups analogous to those for trial division. It's only necessary to list those numbers $a \leq \sqrt{n}$ in your list to look for something with a common factor, for example.