Approximated (unsorted) square from a set of values So a colleaque came with this problem lately and I want to challange you to solve the problem in the code-golf style, shortest solution in any language wins.

The Problem:

Given is a random set of values, where the values themselfs are 
not the concern, but the amount (which is random as well)of values.

To keep the posts readable, let's limit the amount of values to 200, but the program must be able to handly any amount of values, which the language supports.

Input:
No Input needet, due the programm should set an random amount of values (limited to 200).

Output:
Can be text or graphic(px)
I recommend to use single digits as values if you use text based output, to keep the output clear.

Example:

{1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7}   -- Amount : 16


Now you should sort these values in a approcimated square matrix like:

1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
(4 x 4)


Pretty simple so far, if not boring.

But now the challange:

The number of fields in the matrix must be equivalent to the amount of values given.
No empty fields or ignored values are allowed.

As an example, with 12 values, an square matrix is not possible, so you have to find the next aproximitation to it, which is 3x4 or 4x3 but NOT 4x4.

For any prime, the matrix would be 1 x prime

Examples:

For 12 Values:

1 2 3 4
5 6 7 8
9 1 2 3
X X X X   &lt;- NOT ALLOWED, it makes the matrix square, but inserts non existing values.


or

1 2 3
4 5 6 
7 8 9 
1 2 3


For 35 Values:

1 2 3 4 5 6 7
8 9 1 2 3 4 5
6 7 8 9 1 2 3
4 5 6 7 8 9 1
2 3 4 5 6 7 8
Mathematica, 91 bytes

n=RandomInteger@199+1
TableForm@Partition[Range@9~RandomChoice~n,Divisors@n~Nearest~Sqrt@n]


I hope I got this right:


Generate a random length between 1 and 200 (inclusive).
Generate a list of that length with numbers from 1 to 9 (inclusive).
Find one of the two divisors closest to the square root, with Divisors@n~Nearest~Sqrt@n.
Break the list into rows of that length.
Display the grid with TableForm.


Example run: