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$
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$
  • $\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 '14 at 22:15
  • $\begingroup$ @Maesumi: I edited my answer to do multi-columns. $\endgroup$ – DumpsterDoofus Oct 2 '14 at 22:31

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.