# Solving $p^2=2xq^2+2yq+1$ [duplicate]

What are the conditions of solvability of the equation $p^2=2xq^2+2yq+1$ where

$p,q$ being prime and $x,y\in \mathbb{N}$?

## marked as duplicate by Dietrich Burde, Daniel W. Farlow, Willie Wong, Watson, QwertySep 23 '16 at 21:15

• math.stackexchange.com/questions/1776734/… – individ Sep 23 '16 at 8:56
• That's hardly relevant, unless we do it the other way around (solving for p, q). I thought we were solving for x, y. Or... are we, really? A clarification is needed. – Ivan Neretin Sep 23 '16 at 9:19
• Solving for x,y is preferred. – Kurtul Sep 23 '16 at 10:14
• Then the equation is of the form $ax+by=c$, $c=p^2-1$, which has been solved, among many other MSE-questions, here. – Dietrich Burde Sep 23 '16 at 11:23

The right side of the equation is an odd number, therefore $p$ too.
$q$ devides $p+1$ or $p-1$. Therefore $p:=2kq\pm 1$, $k\in\mathbb{N}$.
$(2kq\pm 1)^2=4k^2 q^2\pm 4kq +1=2xq^2+2yq+1$
You can set $x=2k^2$ and $y=\pm 2k$ independend of $q$.
Because of $y>0$ (means $y=2k$) you can only choose $p:=2kq+1$.