Finding the digits in base $26$

89 Views Asked by At

Let $s = (s_0, \dots, s_k)$ with $0 \leq s_i \leq 25 \ \forall i$, and $f(s) = s_0 26^0 + s_1 26^1 + s_2 26^2 + \dots + s_{k-1} 26^{k-1}$.

Is it possible, and if so how, to find all the $s_i$ knowing $f(s)$?

For example, if $s = (4, 1, 2, 3)$ then $f(s) = 4 \cdot 1 + 1 \cdot 26 + 2 \cdot 676 + 3 \cdot 17576 = 54110$. How would one go about finding all the $s_i : 4, 1, 2, 3$ from $f$ and its result $54110$?

Ps: I'm a bit of a math novice, so I'd appreciate a "noob friendly" version of an answer.

3

There are 3 best solutions below

2
On BEST ANSWER

Let's recall the algortihm for compuing the decimal digits of a natural $\rm \,n.$

Let $\rm \,D(n)\,$ be the list of digits of $\rm\,n\,$ and let $\,\sqcup\,$ denote list concatenation.

By division $\rm\, n = 10 q + r\ $ for $\rm \,r = n\bmod 10,\ $ where $\rm \ 0\le r < 10$

Hence $\rm \, D(n) = D(q) \sqcup [r],\, $ which leads to the following algorithm

$\qquad\ \ \ \begin{align} \text{D(n) := }& \text{if $\rm \ n < 10\ $ then $\rm \,[\,n\,]$}\\ &\text{else let $\rm \{\,r = n\bmod 10;\ \ q = (n\!-\!r)/10\,\}$}\\ &\qquad\ \ \rm D(q)\sqcup [\,r\,] \end{align}$

The above algorithm works for any radix $\rm\,b\,$ by replacing $\,10\,$ by $\rm \,b\,$ above.

9
On

Try with smaller basis - 2,8,10,... The algorithm will be analogous, for example:

$s_0 = f(s) (\mod 26^1) $

$s_1 = (f(s) - s_026^0)(\mod 26^2) $

...

$s_n = \left(f(s)-\sum_{k=0}^{n-1}s_k 26^{k}\right)(\mod 26^{n+1})$

0
On

The algorithm is like this. The example 231 base 4.

enter image description here