Storing Multiple solutions from Solve as rows of a matrix

I am trying to find all the solutions to a Diophantine equation (only integer valued solutions) using Solve[], however there are multiple and even many solutions sometimes.

How can I store these individual solutions as rows of a matrix?

When I apply the rules to the variables, and then display as table, or matrix, and then get the dimension of the resulting "table", it appears that it is just one long vector, and not a matrix as it appears.

For example: Solve[2/3-1/x-1/y-1/z==0 &&x>=1 &&y>=x &&z>=y,{x,y,z},Integers]. This produces 8 solutions of the form (x,y,z). So I would like each solution to be an individual row in an 8x3 matrix.

• Solve[2/3 - 1/x - 1/y - 1/z == 0 && x >= 1 && y >= x && z >= y, {x, y, z}, Integers][[All, All, 2]], maybe? – user1066 Jul 19 '17 at 15:06

eq = 2/3 - 1/x - 1/y - 1/z == 0 && x >= 1 && y >= x && z >= y;
var = {x, y, z};
(mat = var /. Solve[eq, var, Integers]) // MatrixForm
Dimensions[mat]


$\left( \begin{array}{ccc} 2 & 7 & 42 \\ 2 & 8 & 24 \\ 2 & 9 & 18 \\ 2 & 10 & 15 \\ 2 & 12 & 12 \\ 3 & 4 & 12 \\ 3 & 6 & 6 \\ 4 & 4 & 6 \\ \end{array} \right)$
{8, 3}

• I have done that, but when I go to store this as a matrix, it turns out to be a 1x24 matrix with just each row appended to each other. – Matthew Crawford Jul 19 '17 at 13:04
• @MatthewCrawford The above code yields a 8x3 matrix. What code did you use? – Coolwater Jul 19 '17 at 13:07
• Table3=({x,y,z}/. Solve[2/3-1/x-1/y-1/z==0 && x>=1 && y>=x && z>=y,{x,y,z},Integers])//MatrixForm Dimensions[Table3] – Matthew Crawford Jul 19 '17 at 13:13
• You store a MatrixForm in Table3, because // MatrixForm has higher precedence than Table3 = . If you left click 3 times fast on "//" you can see how the code is parsed – Coolwater Jul 19 '17 at 13:17