# Quadratic equations with prime coefficients

I recently decided to go through old high school notebooks and I found something marginally interesting. I used to note down all kinds of things I came across, and I thought this might be useful for an after school algebra class I'm currently teaching. These are all quite trivial, I'm looking for any assumptions I missed, and whether it can be generalized to higher order polynomials.

The original problem in my notes was stated as

Given a function $f(x)=x^2+qx+p$ where $q$ is composite and $p$ prime, assuming $x \in \mathbb{Z}$ (i.e. $\exists$ a factorization over $\mathbb{Z}$), find an expression for the roots of $f$, and hence an expression for $q$ in terms of $p$

I remember stating this as a problem from a textbook to try to formalize my math (I was 16 and overzealous about using $\exists$ and other cool symbols)

If there exists a factorization then the function must be expressible in the form $$f(x)=(x+a)(x+b)$$

Because $p$ is prime, its only factors are $p$ and $1$, hence $$f(x)=(x+1)(x+p)$$ And thus by expansion, one would find that $q=1+p$

Seems to work out all right. Similarly, $f(x)=x^2+qx-p$ has factorization $(x-p)(x+1)$ or $(x-1)(x+p)$, which gives $q_1 = 1-p$ and $q_2=p-1$

And for $f(x)=x^2-qx+p$, $q=-1-p$

I remember having use of these in my old algebra exams and thought I would pass them on to the class I'm teaching, but I'm always paranoid about missing something. I was originally going to post this to /r/math but the folks there are quite resentful of anything that isn't p-adic number theory or of an equivalent difficulty.

I also found a cute 'proof' of a similar thing on the following page of my notes

For a function $f(x)=x^2+qx+p$, $p$ prime. Assuming $f$ has a factorization over $\mathbb{Z}$, show that $q$ is necessarily composite.

Proof by contradiction: Assume $q = p'$ where $p'$ is prime, hence $f(x)=x^2+p'x+p$. By assumption, $f$ is factorizable, and hence must be expressible as $(x+1)(x+p)$, which by expansion yields $p'=p+1$ and thus cannot be prime and is therefore composite.

The whole thing was a nice trip memory lane regardless.

EDIT: I have never seen this elsewhere so I assumed that either

1. It is trivial enough that it's not mentioned anywhere
2. It's wrong (although I can't see why)

I assume it's (1), though I just don't want to pass this off as knowledge until I'm completely certain, as I mentioned, I'm a bit paranoid about these things.

As pointed out by a commenter, the above result holds for $p>2$

-
What about $\,(x-1)(x-p)\,?\ \$ –  Bill Dubuque Jan 11 at 4:47