Update: I add at the end an illustration of the reverse process of base b to decimal conversion
I have not tried to do the upgoing arrow... I am sorry for all those @ which render the code barely readable (to me). I originally used \n, \m etc... but one always fears overwriting something in LaTeX.
The method uses an expandable loop inside a tabular, so as to get alignment on the right. No test is done on the input which should not be negative.
I do a little play with local and global assignments but maybe using one more count variable would give a more easily readable code. The point anyhow is that computations should not be done twice, despite the restricted scope due to the tabular cell.
When the base is $\leq 36$, the digits use the alphabet starting with $10 = A$.
The base is the optional argument. Please do not use 1...
\documentclass{article}
\usepackage[left=1cm, right=2cm, vmargin=1cm]{geometry}
% expandable loop (used to avoid scope problems in tabular cells with the
% standard \loop)
\def\boucle #1\repeat {#1\b@@cle {#1}\repeat \repeat }
\def\b@@cle #1{\repeat #1\b@@cle {#1}}
\makeatletter
\newcount\@nn
\newcount\@mm
\newcount\@base
\newcount\@baseminusone
% please do not use this at home
% #1 must be a counter name, not something expanding to a number.
\def\@arabalpha #1{\ifcase #10\or1\or2\or3\or4\or5\or6\or7\or8\or9\or
A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or N\or O\or
P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\fi}
\newcommand{\baseexpansion}[2][2]{% no negative numbers please!
\def\@digits{}%
\@base#1\relax \@baseminusone\@base\advance\@baseminusone-1
\@nn #2\relax % this is the number to be written in base #1
%
\ifnum\@baseminusone<36
\def\onerow{#1\kern.1em\hbox{\vrule
\vtop {\hbox{\ \the\@nn}\kern.3ex\hrule height.1ex }} &%
\global\@mm\@nn \global\divide\@mm\@base
\multiply\@mm\@base \advance\@nn-\@mm
\the\@nn \xdef\@digits{\@arabalpha\@nn\@digits}}%
\else
\def\onerow{#1\kern.1em\hbox{\vrule
\vtop {\hbox{\ \the\@nn}\kern.3ex\hrule height.1ex }} &%
\global\@mm\@nn \global\divide\@mm\@base
\multiply\@mm\@base \advance\@nn-\@mm
\the\@nn \xdef\@digits{\the\@nn.\@digits}}%
\fi
%
\leavevmode\oalign{$#2_{10}:$\hfil\cr
$\left.
\begin{tabular}{r|l}
\boucle \onerow \\ \ifnum\@nn>\@baseminusone\global\@nn\@mm \repeat
\end{tabular}\right\rbrace=
\mathtt{\@digits}_{#1}$}} % \hfil removed from the macro
\makeatother
\begin{document}\thispagestyle{empty}
\lineskip12pt
\baseexpansion{1000}\hfil
\baseexpansion[3]{1000}\hfil
\baseexpansion[4]{1000}\hfil
\baseexpansion[5]{1000}\hfil
\baseexpansion[6]{1000}\hfil
\baseexpansion[7]{1000}\hfil
\baseexpansion[8]{1000}\hfil
\baseexpansion[9]{1000}\hfil
\baseexpansion[10]{1000}\hfil
\baseexpansion[11]{1000}\hfil
\baseexpansion[12]{1000}\hfil
\baseexpansion[13]{1000}\hfil
\baseexpansion[14]{1000}\hfil
\baseexpansion[15]{1000}\hfil
\baseexpansion[16]{1000}\hfil
\baseexpansion{1024}\hfil
\baseexpansion[16]{1024}\hfil
\baseexpansion[3]{6561}\hfil
\baseexpansion[111]{1000000}\hfil
\baseexpansion[111]{1000000000}\hfil
\baseexpansion[7]{1000000000}\par
\end{document}


\documentclass{article}
\usepackage[left=1cm, right=2cm, vmargin=1cm]{geometry}
%%%-----------------------------------------------------------------------------
%%% macros to display the computation of a decimal representation of a positive
%%% integer given in base b representation with b at most 36
\makeatletter
\newcount\@nn
\newcount\@mm
\newcount\@base
% globally sets the counter \@mm to the decimal number represented by #1
% which is either a digit 0-9 or a letter A-Z or a-z
% no check on input done!
%\def\@set@mmto #1{\@mm`#1 \advance\@mm-48
% \ifnum\@mm>48 \advance\@mm-39 \else
% \ifnum\@mm>16 \advance\@mm-7 \fi\fi \global\@mm\@mm}
% I had initially:
\def\@set@mmto #1{\@mm`#1
\ifnum\@mm>96 \advance\@mm-87 \else
\ifnum\@mm>64 \advance\@mm-55 \else
\advance\@mm-48 \fi\fi \global\@mm\@mm}
% prepares the first three entries of a row of the future tabular
% \@nn represents the decimal number so far computed, and will
% turn into base times itself plus new digit
% global assignments to transcend cells
\def\@mostofonerow#1{\xdef\@digitssofar{\@digitssofar#1}%
\@set@mmto #1%
$\mathtt{\@digitssofar_{\the@base}}\rightarrow\the\@mm\;$%
&%
${}+\the@base\times\the\@nn$%
\multiply\@nn\@base
\advance\@nn\@mm
\global\@nn\@nn
&${}={}$&}
% this is for displaying the final result in a box
\def\@endfinalrow{\fbox{$\the\@nn_{10}$}\\}
% this is the non-boxed intermediate result ending a row
\def\@endnormalrow{$\the\@nn$\\}
% recursive construction of successive rows
\def\@makenextrows#1{\ifx#1.\@endfinalrow\else
\@endnormalrow\@mostofonerow#1\expandafter\@makenextrows\fi}
% first step for initialization. Checks for empty argument.
\def\@makerows #1{\ifx#1.\else\@mostofonerow#1\expandafter\@makenextrows\fi}
%% actually constructs the tabular with the computation
%% [moved to \todecimal]
%\def\@displayrows #1{{\setlength{\tabcolsep}{0pt}%
% \begin{tabular}[t]{r|lcl}#1\end{tabular}}}
\newcommand{\todecimal}[2][2]{%
\@base=#1\def\the@base{#1}%
\@nn=0
\def\@digitssofar{}%
\oalign{$\mathtt{#2_{#1}}:$\hfil\cr
%%%% replaced
%%%% \expandafter\@displayrows\expandafter{\@makerows #2.}}}
%%%% with the simpler:
{%
\setlength{\tabcolsep}{0pt}%
\begin{tabular}[t]{r|lcl}
\@makerows #2.
\end{tabular}%
}%
}%
} % end ot \todecimal
\makeatother
\begin{document}
\todecimal{0}\medskip
\todecimal{1}\medskip
\todecimal{10101110}\medskip
\todecimal[16]{AE}\medskip
\todecimal[16]{aE}\medskip
\todecimal[7]{351}\medskip
\todecimal[36]{zz}\medskip
\todecimal[36]{xYz}
\end{document}
