Wolfram Language

Algebra and Number Theory

Mixed-Radix Computations

MixedRadix allows working with numerical systems in which different digits of a number correspond to different bases.

These are names of several units of soldiers in a Roman army.

In[1]:=
Click for copyable input
units = {"legion", "cohort", "century", "contubernia", "soldier"};

A legion was made of 10 cohorts, a cohort of 6 centuries, a century of 10 contuberniae, and a contubernia of 8 soldiers.

In[2]:=
Click for copyable input
bases = MixedRadix[{10, 6, 10, 8}];

Number of soldiers in a contubernia, using this number system.

In[3]:=
Click for copyable input
FromDigits[{1, 0}, bases]
Out[3]=

Number of soldiers in a century.

In[4]:=
Click for copyable input
FromDigits[{1, 0, 0}, bases]
Out[4]=

Number of soldiers in a cohort.

In[5]:=
Click for copyable input
FromDigits[{1, 0, 0, 0}, bases]
Out[5]=

Number of soldiers in a legion.

In[6]:=
Click for copyable input
FromDigits[{1, 0, 0, 0, 0}, bases]
Out[6]=

Vice versa, decompose the number of soldiers in these tactical units.

In[7]:=
Click for copyable input
IntegerDigits[16894, bases]
Out[7]=
In[8]:=
Click for copyable input
IntegerDigits[16894, bases]; Thread[units -> %]
Out[8]=

Related Examples

de es fr ja ko pt-br ru zh