2
$\begingroup$

Suppose i want to print numbers in a loop/table For[n = 1, n < 31, n++, Print[BaseForm[n ,7]]]

the output comes with numbers left adjusted. How Can I make them right adjusted?

$\endgroup$

1 Answer 1

5
$\begingroup$

Try using Column and Alignment:

Column[BaseForm[#, 7] & /@ Range[30], Alignment -> Right]

which produces the following right-adjusted output:

enter image description here

Thanks, how would you make a multi-column. Say I also want to print i in base 5 in a second column?

Try this:

Grid[Outer[BaseForm[#1, #2] &, Range[30], Range[2, 16]], Alignment -> Right]

which produces this:

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks, how would you make a multi-column. Say I also want to print i in base 5 in a second column? $\endgroup$
    – Maesumi
    Oct 2, 2014 at 22:15
  • $\begingroup$ @Maesumi: I edited my answer to do multi-columns. $\endgroup$ Oct 2, 2014 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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