I'd like to point out that solving these equations is equivalent to trial factorization of the number
$6n\pm1$ under consideration. Take the first of the four equations and rewrite it in terms of say
$z=6n-1$:
z = 6n-1 /. n->(6s^2 + (6s-1)(m-1) ) // Simplify
(-1 + 6 s) (-5 + 6 m + 6 s)
The second equation picks out the complementary set of possible factors:
z = 6n-1 /. n->(6s^2 +6s + 1 + (6s+1)(m-1) ) // Simplify
(1 + 6 s) (-1 + 6 m + 6 s)
For example, the first composite
$6n-1$ for
$n=6$ (
$z=35$) has a solution to
$(1a(1))$ of
${s=1,m=1}$; this corresponds to the factors
$6s-1=5$ and
$6s+6m-5=7$.
We can similarly manipulate the equations
$(1b)$ to find their algebraic factorizations for any
$z'=6n+1$.
The functions PrimeQ[]
and NextPrime[]
will be faster than solving these equations (i.e., trial factorization).