[Question]
  [
Your task is to decompose a number using the format below.
This is similar to base conversion, except that instead of listing the `digits` in the base, you list the `values`, such that the list adds up to the input.
If the given base is \$n\$, then each number in the list must be in the form of \$k\times n^m\$, where \$0\le k<n\$ and \$m\$ is unique throughout the list.
# Specs
* Any reasonable input/output format. Your program/function takes 2 inputs and outputs a list.
* Output list can be in any order.
* `0` can be excluded or included.
* Leading `0`s are allowed.
* Built-ins are **allowed**.
# Testcases
```
number base   converted list
input1 input2 output
123456 10     [100000,20000,3000,400,50,6] or [6,50,400,3000,20000,100000]
11     2      [8,2,1] or [0,0,0,0,8,0,2,1]
727    20     [400,320,7]
101    10     [100,1] or [100,0,1]
```
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest solution in bytes wins.
  
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
lr0⁹*×b
```
[Try it online!](http://jelly.tryitonline.net/#code=bHIw4oG5KsOXYg&input=&args=MTIzNDU2+MTA) or [verify all test cases](http://jelly.tryitonline.net/#code=bHIw4oG5KsOXYgrDpyJH&input=&args=WzEyMzQ1NiwgMTEsIDcyNywgMTAxXQ+WyAgICAxMCwgIDIsICAyMCwgIDEwXQ).
### How it works
```
lr0⁹*×b  Main link. Arguments: x (integer), n (base)
l        Compute the logarithm of x to base n.
 r0      Range; yield all non-negative integers less than the logarithm, in
         decreasing order.
   ⁹*    Elevate n to all integers in that range.
      b  Yield the list of base-n digits of x.
     ×   Multiply each digit by the corresponding power of n.
```
[Answer]
## JavaScript (ES6), 47 bytes
```
f=(n,b,p=1,q=b*p)=>[...n<q?[]:f(n,b,q),n%q-n%p]
document.write("<pre>"+
[ [ 123456, 10 ], [ 11, 2 ], [ 727, 20 ], [ 101, 10 ] ]
.map(c=>c+" => "+f(...c)).join`\n`)
```
[Answer]
## Jelly, 12 bytes
```
bLR’*@€U
b×ç
```
Can be waaaay shorter...
[Try it online!](http://jelly.tryitonline.net/#code=YkxS4oCZKkDigqxVCmLDl8On&input=&args=MTIzNDU2+MTA)
[Answer]
# Pyth - ~~12~~ 11 bytes
Just a FGITW, can be shorter.
```
.e*b^Qk_jEQ
```
[Test Suite](http://pyth.herokuapp.com/?code=.e%2ab%5EQk_jEQ&test_suite=1&test_suite_input=10%0A123456%0A2%0A11%0A20%0A727%0A10%0A101&debug=0&input_size=2).
[Answer]
# J, ~~20~~ 19 bytes
```
[(]*(^<:@#\.))#.inv
```
## Usage
```
   f =: [(]*(^<:@#\.))#.inv
   10 f 123456
100000 20000 3000 400 50 6
   2 f 11
8 0 2 1
   20 f 727
400 320 7
   10 f 101
100 0 1
```
## Explanation
```
[(]*(^<:@#\.))#.inv
              #.      Given a base and list of digits in that base,
                      converts it to an integer in base 10
                inv   Power conjunction by -1, creates an inverse
                      Now, this becomes a verb that given a base and an integer in base 10,
                      creates a list of digits in that base representing it
[                     Select the base and pass it along
         #\.          Tally each suffix of the list of base digits,
                      Counts down from n to 1
      <:              Decrements each value
        @             More specifically, decrement is composed with the tally and applied
                      together on each suffix
     ^                Raises each value x using base^x
  ]                   Selects the list of base digits
   *                  Multiply elementwise between each base power and base digit
```
[Answer]
## CJam, 16 bytes
```
{1$b\1$,,f#W%.*}
```
An unnamed block that expects the base and the number on top of the stack (in that order) and replaces them with the digit list (including internal zeros, without leading zeros).
[Test it here.](http://cjam.aditsu.net/#code=727%2020%0A%0A%7B%3AX%3B%7BXmdXW)%3AW%23*p%7Dh%3B%7D%0A%0A~&input=20%20727)
### Explanation
```
1$  e# Copy base b.
b   e# Compute base-b digits of input number.
\   e# Swap digit list with other copy of b.
1$  e# Copy digit list.
,   e# Get number of digits M.
,   e# Turn into range [0 1 ... M-1].
f#  e# Map b^() over this range, computing all necessary powers of b.
W%  e# Reverse the list of powers.
.*  e# Multiply each digit by the corresponding power.
```
[Answer]
# TSQL, 68 bytes
```
DECLARE @ INT=123456,@z INT=10
DECLARE @l INT=1WHILE
@>0BEGIN PRINT @%@z*@l SELECT @/=@z,@l*=@z END
```
[Answer]
# Mathematica, 46 bytes
```
DiagonalMatrix@IntegerDigits@##~FromDigits~#2&
```
**Explanation:**
```
In[1]:= IntegerDigits[123456,10]                                                
Out[1]= {1, 2, 3, 4, 5, 6}
In[2]:= DiagonalMatrix@IntegerDigits[123456,10] // MatrixForm                   
Out[2]//MatrixForm= 1   0   0   0   0   0
                    0   2   0   0   0   0
                    0   0   3   0   0   0
                    0   0   0   4   0   0
                    0   0   0   0   5   0
                    0   0   0   0   0   6
In[3]:= DiagonalMatrix@IntegerDigits[123456,10]~FromDigits~10                   
Out[3]= {100000, 20000, 3000, 400, 50, 6}
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
bḅ²×¥@b×
```
[Try it online!](https://tio.run/##y0rNyan8/z/p4Y7WQ5sOTz@01CHp8PT///8bGoAAkAIA "Jelly – Try It Online")
`²×¥@` seems too long for what it does. I hope there is a shorter way.
### Explanation
```
b             Convert A (the input number) to base B (the input base).
 ḅ²×¥@        Convert from base A×B²
      b×      Convert to base A×B
```
[Answer]
# Regex (ECMAScript), 76 bytes
```
(?=.*,(x(x*)))(?=.*?(((?=(?=\1*,)(x(x*))(?=\5*,)(?=\2+,)(\2\6*),)\7)*x),)\3+
```
Takes its input in unary, as the length of two string of `x`s delimited by a `,` (number first, then base). Returns its result as the list of matches (each is also a string of `x`s whose length is the value).
[Try it online!](https://tio.run/##TU/BUsIwFLz7FZUDfa8NtSkoM9TAyYMXD3oEDgFiSU1DJwlSRa5@gJ/oj2CKOOPMm9m3b2dn35b8ldulkbXr2VquhKk2@kW8HQ3TYhc8iuKuqQHe2fgqOsKEJRGBBpoIEU9sAuDRz4xGBM9SS69b6jGLPc6y2U2EBGdDjJoW@/ExunrHxG2enJG6AEyskksBN6Q3QBKERYi5ZWm@W0slABQzgq@U1AIQL5neKoX7BaNpXjCV2FpJByHxHvkMoFmRKKELt8Zx9vEh7QN/AMlqbqy41w6KaTpH/BMW/wU9phM6amV0a7PZde71K1dyFRiuCzEKOrFqIyoGYRMmRtSCO5AY@@z432WBmFTcLddgEPe22619SQdtJZrXW2edAXkyLeIw@P78CvzrzxsDpa9c3lbn9/MyjnFfevuv5dTwvFfTcv7X8pAfDkea9QeEpheUkuximA1J5veU@tMP "JavaScript (SpiderMonkey) – Try It Online")
It's a good thing the challenge allows `0` to be excluded or included, because this solution excludes it, and it would not be possible to include it! (The only way to include it would be either to use .NET with the result returned via a capture's stack, or PCRE with a callout.)
The division algorithm is explained in my [Division and remainder](https://codegolf.stackexchange.com/a/222932/17216) post.
```
# If this is the first match, tail = N = input number. Otherwise
# tail = N = current intermediate value, which is the input number
# after having the previous return values all subtracted from it.
(?=
    .*,(x(x*))             # \1 = number base; \2 = \1 - 1
)
(?=
    .*?                    # Decrease tail by the minimum necessary to satisfy
                           # the following assertion:
    # Assert tail is a power of \1; \3 = tail = the largest power of \1 that is
    # less than or equal to N.
    (                      # \3 = tail
        (
            (?=
                # Calculate \5 = tail / \1
                (?=\1*,)   # Assert tail is divisible by \1
                (x(x*))    # \5 = quotient - find the largest that matches the
                           #      following assertions; \6 = \5-1; tail -= \5
                (?=\5*,)   # assert tail is divisible by quotient
                (?=\2+,)   # assert tail is positive and divisible by divisor-1
                (\2\6*),   # assert tail-(divisor-1) is divisible by quotient-1;
                           # \7 = tool to make tail = \5
            )\7            # tail = \5
        )*                 # Iterate the above as many times as possible
        x                  # tail -= 1
    )
    ,                      # Assert tail == 0
)
\3+                        # Return value = M = tail - (tail % \3); tail -= M
```
[Answer]
# Mathematica, 12 bytes
I wonder whether Wolfram Research created this function after seeing the OP's challenge!
```
NumberExpand
```
This was introduced in version 11.0 (August, 2016).
[Answer]
## Python 2, 44 bytes
```
lambda n,b:[n/b**i%b*b**i for i in range(n)]
```
Outputs from least significant to most, with many extra zeroes.
To output most significant to least:
```
f=lambda n,b,c=1:n*[1]and f(n/b,b,c*b)+[n%b*c]
```
Recurse, repeatedly taking digits off of `n` with divmod while scaling up the place value multiplier `c`.
[Answer]
# Ruby, ~~35~~ 34 bytes
This is a port of [xnor's Python answer](https://codegolf.stackexchange.com/a/79328/47581), but it prints `n` times so the test case `727 20` prints `7`, `320`, `400`, and 724 `0`s. Golfing suggestions welcome.
**Edit:** 1 byte thanks to Jordan.
```
->n,b{n.times{|i|p n/b**i%b*b**i}}
```
[Answer]
## [Pip](http://github.com/dloscutoff/pip), 13 bytes
```
Wa-:Pa%oo*:b
```
Doing it the old-fashioned way turned out to be shorter than using the `TB` base-conversion operator. The code runs a while loop until `a` (the number) is `0`. At each iteration, it prints `a%o` and subtracts it from `a`. `o` is preinitialized to `1` and gets multiplied by `b` (the base) each iteration. (This approach keeps all `0`s and also adds a leading `0`.)
[Try it online!](http://pip.tryitonline.net/#code=V2EtOlBhJW9vKjpi&input=&args=MTE+Mg)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `r`, 7 bytes
```
τ:ẏṘ⁰e*
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJyIiwiIiwiz4Q64bqP4bmY4oGwZSoiLCIiLCI3MjdcbjIwIl0=)
A nice little answer. Takes `value` then `base`
## Explained
```
τ:ẏṘ⁰e*
τ       # Convert value from base 10 to input base
 :ẏṘ    # Duplicate that and push the range [len(that) - 1, 0]
    ⁰e  # Raise base to the power of each item in that
      * # Multiply that by the list of digits of the converted value
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 44 bytes
```
b=>g=n=>n?[...g(~~(n/b)).map(i=>i*b),n%b]:[]
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEts/ifZvs/ydYu3TbP1i7PPlpPTy9do65OI08/SVNTLzexQCPT1i5TK0lTJ081KdYqOvZ/cn5ecX5Oql5OfrpGmoahgaaGoZGxiamZpqY1F6qcEVDKEIswUIu5kTmmBNgsA5CO/wA "JavaScript (V8) – Try It Online")
Takes [curried](https://en.wikipedia.org/wiki/Currying) input in the form `function(base)(number)`.
[Answer]
# [Desmos](https://desmos.com/calculator), 57 bytes
```
k=b^{[floor(log_b(n+0^n))...0]}
f(n,b)=mod(floor(n/k),b)k
```
[Try It On Desmos!](https://www.desmos.com/calculator/ptlp4vaug9)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/9twbhzm65q)
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 18 bytes
```
-⟜»⊢|˜⊣⋆1+·↕∘⌈⊣⋆⁼+
```
Tacit function; takes the base as left argument and the number as right argument. [Try it at BQN online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgLeKfnMK74oqifMuc4oqj4ouGMSvCt+KGleKImOKMiOKKo+KLhuKBvCsKCjIwIEYgNzI3)
### Explanation
Call the left argument `b` and the right argument `n`.
```
-⟜»⊢|˜⊣⋆1+·↕∘⌈⊣⋆⁼+
                ⋆⁼   Inverse exponential (i.e. logarithm)
               ⊣     with base b
                  +  of b + n
              ⌈       Round up to nearest integer
                     This number is at least as large as the number of base-b digits n has
            ↕∘       Range (0-based, exclusive)
         1+·         Add 1 to each
       ⊣⋆            Raise b to each of those exponents
    ⊢|˜              Take n mod each of those powers of b
   »                 Shift a copy of that list right, prepending a 0
-⟜                  and subtract it from the unshifted list
```
For example, with a base of 3 and a number of 17, we have
```
+       20
⊣⋆⁼     2.726833027860842
1+·↕∘⌈   ⟨ 1 2 3 ⟩
⊣⋆      ⟨ 3 9 27 ⟩
⊢|˜     ⟨ 2 8 17 ⟩
»       ⟨ 0 2 8 ⟩
-⟜     ⟨ 2 6 9 ⟩
```
[Answer]
# Racket, 82 bytes
```
(define(d n b[a'()])(if(< n 1)a(d(/ n b)b(cons(*(modulo(floor n)b)(length a))a))))
```
*I'm a winner (!)*
[Answer]
# JavaScript (ES7), 68 bytes
```
n=>b=>(c=[...n.toString(b)]).map(d=>b**--p*parseInt(d,b),p=c.length)
```
## Test
Test uses `Math.pow` for browser compatibility.
```
f=n=>b=>(c=[...n.toString(b)]).map(d=>Math.pow(b,--p)*parseInt(d,b),p=c.length)
document.write("<pre>"+
[ [ 123456, 10 ], [ 11, 2 ], [ 727, 20 ], [ 101, 10 ] ]
.map(c=>c+" => "+f(c[0])(c[1])).join`\n`)
```
[Answer]
# JavaScript, 75 bytes
```
(a,b)=>[...a.toString(b)].reverse().map(($,_)=>Math.pow(b,_)*parseInt($,b))
```
Just for fun :)
It could be golfed more, but I'm not too sure how.
## ES7, 66 bytes
If ES7 is allowed then:
```
(a,b)=>[...a.toString(b)].reverse().map(($,_)=>b**_*parseInt($,b))
```
[Answer]
# [O](https://github.com/phase/o), 17 bytes
```
jQb`S/l{#Qn^*p}d
```
Two notes:
1. **The third test case does not work due to a bug with base conversion.** See [phase/o#68](https://github.com/phase/o/issues/68).
2. This does not work in the online interpreter. `b` hadn't been implemented yet.
[Answer]
# ><>, 28 bytes
```
:&\
&*>:{:}$%:n$}-:0=?;ao$&:
```
Expects the input values to be present on the stack at program start.
As ><> doesn't have list objects, the output is presented as a newline-separated list of values, with the 'units' on the first line. An example run:
```
Input: 
11 2
Ouput:
1
2
0
8
```
@OP, if this isn't an acceptable output format, let me know and I'll edit the answer accordingly.
[Answer]
# PHP, 55 bytes
Uses Windows-1252 encoding.
```
for($n=$argv[1];$d+$n-=$d=$n%$argv[2]**++$i;)echo$d,~Ó;
```
Run like this (`-d` added for aesthetics only):
```
php -d error_reporting=30709 -r 'for($n=$argv[1];$d+$n-=$d=$n%$argv[2]**++$i;)echo$d,~Ó; echo"\n";' 123056 10
```
[Answer]
## C#, 77 bytes
```
IEnumerable _(int n,int b){int m=1;while(n>0){yield return n%b*m;n/=b;m*=b;}}
```
[Answer]
# C++, 82 Bytes
```
int*f(int n,int b){int*a,o[n]{b,n%b};for(a=o+1;*a=(n-=*a++)%(b*=*o););return o+1;}
```
The main loop is pretty trivial (keep taking modulos and subtracting the lower part). The main savings come from doing lots of calculations in-place and the loop condition being the actual assigned value (which will eventually become 0, after all meaningful output is written to the array)
I haven't been able to figure out why, but ideone throws a runtime error if I try to have the function return `o` instead of `o+1`, so I use the extra index to store the powers of b.
[Answer]
## Actually, 17 bytes
```
;a¡;lrR(♀ⁿ@♂≈♀*;░
```
[Try it online!](http://actually.tryitonline.net/#code=O2HCoTtsclIo4pmA4oG_QOKZguKJiOKZgCo74paR&input=MTIzNDU2CjEw)
Explanation:
```
;a¡;lrR(♀ⁿ@♂≈♀*;░
                   initial stack: [b n] (b = base, n = number)
;                  dupe b
 a                 invert stack
  ¡                n as a base-b integer
   ;lrR            dupe, length, range, reverse
       (♀ⁿ         raise b to each power in range
          @♂≈      create list of integers from base-b string
             ♀*    pairwise multiplication
               ;░  filter out zeroes
```
]