Decomposition of Numbers
NumberDecompose expresses a number into multiples of units, like currency denominations.
The Bahamian currency (BSD) uses the following banknote denominations.
In[1]:=
denominations = {100, 50, 20, 10, 5, 3, 2, 1, 1/2};
BSD allows for more possible ways of breaking a given amount into bills relative to other currencies due to the presence of the BSD 3 note. These are the quotients between consecutive denominations.
In[2]:=
Divide @@@ Subsequences[denominations, {2}]
Out[2]=
In most currency systems, only quotients 2 and 5/2 are present, but in this case there are also 5/3 and 3/2.
In[3]:=
Divide @@@ Subsequences[denominations, {2}];
BarChart[%]
Out[3]=
Decompose an amount of Bahamian dollars in the available banknote denominations.
In[4]:=
NumberDecompose[598.50, denominations]
Out[4]=
Recover the initial amount using NumberCompose.
In[5]:=
NumberCompose[{5, 1, 2, 0, 1, 1, 0, 0, 1.}, denominations]
Out[5]=
This is the amount of money obtained with a banknote of each denomination.
In[6]:=
NumberCompose[Table[1, Length@denominations], denominations] // N
Out[6]=