Given $a \in \mathbb{Z}$ with $a > 1$. Let $g(x) \in \mathbb{Z}[x]$ be a polynomial with $g(a)=\pm 1$. Let $h(x) \in \mathbb{Z}[x]$ be a polynomial with $h(a)= p$, a prime. Let $g(x)$ and $h(x)$ have not all coefficients negative nor positive. Can $g(x)h(x)$ have only positive or only negative coefficients? Is there a way to generate such polynomials? What if $a < 1$? The motivation is to test if a given polynomial has only positive coefficients and assumes a prime value at a positive integer larger than $1$, then it is irreducible. 


I got good answers for the above question. The answer includes the phrase "...the last few coefficients of $g(x)h(x)$ are large enough...". Is there a way to overcome this?


Adding one additional constraint: 


The given polynomials $g(x)$ and $h(x)$ have constant coefficient $\pm 1$ with $g(x)h(x)$ having constant coefficient $1$, $g(a)h(a)$ a prime for some $a > 1$, say $a=2$.



On reducible polynomials with positive coefficients, $1$ as constant coefficient and certain bounds on coefficients
$$
 g(x)h(x)=(x^2-4x+5)(x^{14}+5x^{13}+16x^{12}+40x^{11}+81x^{10}+125x^9+96x^8
$$
$$
 \qquad -x^7+6x^5+25x^4+71x^3+160x^2+286x+355)
$$
$$
=x^{16}+x^{!5}+x^{14}+x^{13}+x^{12}+x^{11}+x^{10}+240x^9+484x^8
$$
$$
 + x^7 + x^6 + x^5 + x^4 + x^3 + 11x^2 + 10x + 1775.
$$
$g(2)=1$, $h(2)=378919$.


In fact, it is known that each polynomial with no nonnegative real roots has a multiple with only positive coefficients. Moreover, there exists a large variety of such polynomials, hence there is nothing special in such an example. 


So, having obtained $h(x)$ such that the last few coefficients of $g(x)h(x)$ are large enough, you may change few its last coefficients to make $h(a)$ prime. That's how this concrete example was obtained: first, I have found one by one the coefficients of $h(x)$ so that the first coefficients of the product are ones and the next two are positive, then I have added the negative coefficient and repeated the procedure, and then I have changes the last coefficient to make $h(2)$ prime.


It might be helpful to notice the following fact. If $g(x)$ has a complex root with argument $\alpha$, then each its multiple $p(x)$ with nonnegative coefficients has the degree at least $\pi/\alpha$. To see this, just substitute that root into $p(x)$ and look at the sign of the imaginary part.


**EDIT,** I'm a bit lazy to construct an explicit example with the last coefficients $\pm1$, sorry; but here is the way.


Take $g(x)=x^2(x-2)^2+1$. In the same way you may find the polynomial $h(x)$ such that $g(x)h(x)$ has positive coefficients (and $h(x)$ does not) --- since $g(x)$ has no nonnegative real roots. Next, consider $g\_1(x)=x^4g(1/x)$ and construct the corresponding polynomial $h\_1(x)$, say of degree $n$ (we need $h\_1$ to have $1$ as the leading coefficient; it is surely possible). 


It remains to notice that $g(x)(x^{n+5}h(x)+x^nh\_1(1/x))$ is almost the desired example; you just need to change the appropriate coefficients of $h$ and $h\_1$ to make the corresponding value prime. I am almost sure thath this is possible...


Notice that one may even decrease the exponent $n+5$ (the only fact to check is that the second factor should have a negative coefficient, and that of $h(x)$ is somewhere in the middle). 


