# How can I format 256 items into a column of four grids of 16 rows and 8 columns?

ab = DisplayForm[
GridBox[Flatten /@
Transpose@
Partition[
Table[{n,
FactorInteger[n] /. List[p_Integer, 0] :> HoldForm[p] /.
List[p_Integer, k_Integer] :> HoldForm[p^k] /.
List[x__] :> Times@x /. {} -> 1}, {n, 1, 256}], 16],
GridFrame -> True, RowLines -> True, ColumnLines -> True]]


result image result that I hope How to I divide 256 by pieces of four of horizontal 4 * vertical 16?

• mathworld.wolfram.com/notebooks/PrimeNumbers/… – jlptrbsa Jan 18 '15 at 23:09
• You edited your desired result to look different than it did. You want to print a series of "tables" down the page? – Mr.Wizard Jan 18 '15 at 23:32
• Yes. I wish result of i.stack.imgur.com/qhRGq.png – jlptrbsa Jan 18 '15 at 23:34
• Please edit the Answer. I wait for edited Answer. – jlptrbsa Jan 19 '15 at 0:25
• Okay. People on this site answer questions voluntarily on their own time, therefore you should be patient. I shall revise my answer when I get around to it. – Mr.Wizard Jan 19 '15 at 0:29

Here is a modularized method. The first function is from Trying to write out the prime factorization of a number with CenterDot and Superscript, slightly modified.

Format[primeFactorForm[n_Integer]] :=
Times @@ Superscript @@@ FactorInteger[n] /. _[x_] :> x

block[n_Integer] :=
Join @@@ Array[{#, primeFactorForm@#} &[# + 16*#2] &, {16, 4}, {64 n - 63, 0}]

grid[m_?MatrixQ] :=
With[{th = AbsoluteThickness}, Grid[m, Dividers -> ({#, #} &@{th, {True}, th})]]

Array[grid @ block @ # &, 4] // Column ## Old answer for original example

There is probably a cleaner way to write this but here's a start for you:

tab = Table[{n,
FactorInteger[n] /. List[p_Integer, 0] :> HoldForm[p] /.
List[p_Integer, k_Integer] :> HoldForm[p^k] /. List[x__] :> Times@x /. {} ->
1}, {n, 1, 256}];

eight   = Prepend[Table[True, {7}], AbsoluteThickness];

sixteen = Prepend[Table[True, {15}], AbsoluteThickness];

Grid[Flatten /@ Transpose@Partition[tab, 16], Dividers -> {{eight}, {sixteen}},
ItemSize -> Full]

• This looks really fun! – Chen Stats Yu Jan 19 '15 at 0:57
• @ChenStatsYu :-P – Mr.Wizard Jan 19 '15 at 1:42