Problem

Source: Regional Olympiad - Federation of Bosnia and Herzegovina 2015

Tags: number theory, coprime



For positive integer $n$, find all pairs of coprime integers $p$ and $q$ such that $p+q^2=(n^2+1)p^2+q$