Digital Sumorial

Canvas, 3 bytes

┬]∑

Try it here!

Canvas beating Jelly?

{ ]   map over 1..input (implicit "{")
 ┬      decode input from that base
   ∑  sum the resulting (nested) array

Haskell, 46 bytes

f n=sum$do a<-[1..n];mapM(pure[0..a])[1..n]!!n

Try it online!

Explanation

The function \b n -> mapM(pure[0..b])[1..n], generates all strings \$[0 \dotsc b]^n\$ in lexicographic order. For example:

mapM(pure[0..2])[0..1] == [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]

By indexing into it with (!!n) this can be used to convert n to base b+1, however this won't work for unary (base-\$1\$), but we're summing the results.. We can even save some bytes with a <- [1..n] and using base-\$(n+1)\$ rather than a work-around for base-\$1\$ since we're missing \$[\underset{n\text{ times}}{\underbrace{1,\dotsc,1}}]\$ which is the same as \$[n]\$ when summing.

Using do-notation just concatenates all the lists instead of nesting them:

λ [ mapM (pure [0..a]) [1..5] !! n | a <- [1..5] ]
[[0,0,1,0,1],[0,0,0,1,2],[0,0,0,1,1],[0,0,0,1,0],[0,0,0,0,5]]

λ do a <- [1..5]; mapM (pure [0..a]) [1..5] !! n
[0,0,1,0,1,0,0,0,1,2,0,0,0,1,1,0,0,0,1,0,0,0,0,0,5]

APL (Dyalog Unicode), 14 bytes

+/∘∊⊢,⊢(⍴⊤⊣)¨⍳

Try it online!

Explanation

Some parentheses are implied and can be added (lighter than the "official" parenthesizing):

+/∘∊(⊢,(⊢(⍴⊤⊣)¨⍳))

This is a monadic atop. Given an argument Y, this function behaves like:

+/∘∊(⊢,(⊢(⍴⊤⊣)¨⍳))Y

The two functions are applied in order. We'll start from the right one:

⊢,(⊢(⍴⊤⊣)¨⍳)

The are three functions in this train, so this is a fork. Given an argument Y, it acts as:

(⊢Y),((⊢Y)(⍴⊤⊣)¨⍳Y)

We can easily reduce to this (monadic returns its argument, hence called identity):

Y,Y(⍴⊤⊣)¨⍳Y

Now, we know that Y is an integer (simple scalar, i.e. number or character), since we're given one. Therefore ⍳Y, with ⎕IO=1, returns 1 2 ... Y. ⍳Y actually returns an array with shape Y (Y must be a vector), where every scalar is the index of itself in the array (that's why monadic is called the index generator). These indices are vectors, except for the case where 1≡⍴Y, where they are scalars (this is our case).

Let's parse the middle function, (⍴⊤⊣)¨, next. ⍴⊤⊣ is the operand of ¨ (each), and the function is dyadic, so the ¨ operator will first reshape each length-1 argument to the shape of the other (that is, take the element and use it to replace every scalar in the other argument), and then apply the function to each pair of the two arguments. In this case, ⍳Y is a vector and Y is a scalar, so, if n≡⍴⍳Y, then Y will be converted to n⍴Y ( represents the shape (monadic) and reshape (dyadic) functions). That is, in simpler terms, Y will be converted to an array containing Y times Y.

Now, for each pair, let's call the left argument X and the right Z (so that we don't conflict with the input Y). ⍴⊤⊣ is a dyadic fork, so it will expand to:

(X⍴Z)⊤X⊣Z

Let's make the easy first step of reducing X⊣Z to X (dyadic is the left function):

(X⍴Z)⊤X

The in X⍴Z is, again, the reshape function, so X⍴Z, in our case, is simply X times Z. is the encode function. Given two arrays of numbers, where the left array is the base of each digit in the result (doesn't need to be integer or positive), i.e. the encoding, and the right is an array of numbers, returns the transposed array of those numbers in the specified encoding (transposition is the reversal of an array's dimensions relative to its elements). The representation of a digit is based on the quotient of the division of the number and the product of the less significant bases. If any base is 0, it acts as base +∞. The arguments' scalars are all simple. Since X is a positive integer, and X⍴Z is a vector of equal elements, this is really just a case of converting X to base Z and reshaping to X digits. For \$X,Z\in\mathbb N\$, \$X_Z\$ (\$X\$ in base \$Z\$) can't have more than \$X\$ digits, since \$X_1\$ has \$X\$ digits. Therefore, X⍴Z is enough for our purposes.

The result of Y(⍴⊤⊣)¨⍳Y is, therefore, Y converted to each base from 1 to Y, possibly with leading zeroes. However, there is one issue: in APL, base 1 isn't special-cased, while this challenge does special-case it, so we have to include the sum of the base-1 digits of Y ourselves. Fortunately, this sum is just Y, since \$Y_1=\underbrace{[1,1,...,1]}_Y\$, so the sum is simply \$Y\times1=Y\$. It follows that we have to add Y somewhere into the array. This is how we do it:

Y,Y(⍴⊤⊣)¨⍳Y

I have already included this part here. Dyadic , is the catenate function, it concatenates its arguments on their last axes, and errors if that's not possible. Here, we simply concatenate the scalar Y to the vector Y(⍴⊤⊣)¨⍳Y, so that we increment the sum we're going to calculate by Y, as explained above.

The final part is the left function of our atop, +/∘∊:

+/∘∊Y,Y(⍴⊤⊣)¨⍳Y

is the compose operator. f∘g Y is the same as f g Y. However, we're using it here so that our train doesn't fork on the . So, we can reduce:

+/∊Y,Y(⍴⊤⊣)¨⍳Y

Now, it's time for the sum, but wait... there's a problem. The array isn't flat, so we can't just sum its elements before flattening it first. The enlist function flattens an array. Now that the array has been flattened, we finally use +/ to sum it. / is the reduce operator, it applies a dyadic function between an array's elements on its second-to-last axis, with right-to-left priority. If the rank (number of dimensions, i.e. length of shape) of the array doesn't decrease, the array is then enclosed, although this is not the case here. The function that's applied here is +, which is the plus function that adds the pairs on the last axes of two arrays (and errors if the arrays can't be added like that). Here, it simply adds two numbers a number of times so that the reduce is completed.

Lo and behold, our train:

+/∘∊⊢,⊢(⍴⊤⊣)¨⍳