2
$\begingroup$

I have a function that should give a multiplication table for an integer input:

TableForm[Outer[Times, Range[#], Range[#]], TableHeadings -> Automatic]&

But, this doesn't display an x in the top-left header cell, like I want. Is there an easy way to put text in that empty label spot? I want the result to look like this (taken from here):

http://www.wolframalpha.com/input/?i=10+multiplication+table

$\endgroup$
4
$\begingroup$

You need Grid

n = 10;
r = Range @ n;

Grid[
 Join[{Join[{"x"}, r]}, Flatten /@ Transpose[{r, Outer[Times, r, r]}]],
 Alignment -> Right,
 Background -> {{1 -> LightGray}, {1 -> LightGray}, {1, 1} -> None},
 Dividers -> {{2 -> True}, {2 -> True}},
 ItemStyle -> Directive[FontSize -> 16],
 Frame -> True,
 Spacings -> {1.5, 1.5}]

enter image description here

Or, to show all dividers, Dividers -> All

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.