# Find all solutions which satisfy the given conditions

Let

$$m=9n^3+30n^2-9n$$

where $n \in \mathbb{Q^{+}}$ and $m \in \mathbb{Z}$ . Find all solutions which satisfy the given conditions.

So I've tried to solve this manually and I was able to receive help but how would I solve this in mathematica.

I would need the input to be a rational but output an integer.

Clearly, integer n satisfies the equation. The question is, are there other solutions? Some sample results reveal a clear pattern.

eqn = m == 9 n^3 + 30 n^2 - 9 n;
DeleteCases[Table[{m, Reduce[eqn && n > 0, n, Rationals]}, {m, 10000}], {_, False}]
(* {{10, n == 2/3}, {30, n == 1}, {110, n == 5/3}, {174, n == 2}, {360, n == 8/3},
{486, n == 3}, {814, n == 11/3}, {1020, n == 4}, {1526, n == 14/3}, {1830, n == 5},
{2550, n == 17/3}, {2970, n == 6}, {3940, n == 20/3}, {4494, n == 7},
{5750, n == 23/3}, {6456, n == 8}, {8034, n == 26/3}, {8910, n == 9}} *)


Thus, n a fraction of the form (2 + 3 I)/3 , with i a positive integer, also satisfies the equation.

If desired, this last result can be written as a function, such as,

ClearAll[m]
m[n_?(# > 0 && (# ∈ Integers || Mod[#, 1] == 2/3) &)] := 9 n^3 + 30 n^2 - 9 n
Attributes[m] = {Listable};
m[{5/3, 3, 2/7, -3}]
(* {110, 486, m[2/7], m[-3]} *)

eqn = m == 9 n^3 + 30 n^2 - 9 n;

Solve[{eqn, Element[m, Integers],
Element[n, Rationals], n > 0}, n] //
Simplify[#, {Element[m, Integers], Element[n, Rationals], n > 0}] &

(*  {{n -> ConditionalExpression[2/3,
m == 10]},
{n -> ConditionalExpression[1,
m == 30]},
{n -> ConditionalExpression[
Root[-m - 9*#1 + 30*#1^2 +
9*#1^3 & , 1],
Element[Root[-m - 9*#1 +
30*#1^2 + 9*#1^3 & , 1],
Rationals] && m >= 71]}}  *)


I'm not sure how to find all of them, but here is a way to find a bunch of answers:

eqn = 9 (p/q)^3 + 30 (p/q)^2 - 9 (p/q);
FindInstance[eqn == m && p > 0 && p != q && p != -q, {{m, p, q} ∈ Integers}, 20]