NumberDecompose

NumberDecompose[x,{u1,,un}]

returns a list of coefficients {c1,,cn} of a decomposition of the number x in the basis {u1,,un}.

Details

  • The basis {u1,,un} must be a list of nonincreasing positive numbers.
  • The result has the same length of the basis, even if the initial coefficients are zero.
  • The coefficients {c1,,cn-1} are integers, but cn will be exact or not depending on the precision of x and the basis elements.

Examples

open allclose all

Basic Examples  (2)

Decompose an amount of money in different denominations:

In[1]:=
Click for copyable input
Out[1]=

Decompose an amount of seconds in days, hours, minutes, and seconds:

In[1]:=
Click for copyable input
Out[1]=

Scope  (2)

Properties & Relations  (6)

See Also

NumberCompose  QuotientRemainder  FrobeniusSolve  IntegerPartitions  IntegerDigits  MixedRadix  DMSList  NumberExpand  TakeList

Introduced in 2015
(10.2)