[Question]
  [
We are used to the term "squaring" *n* to mean calculating *n2*. We are also used to the term "cubing" *n* to mean *n3*. That being said, why couldn't we also triangle a number?
# How to triangle a number?
* First off, let's pick a number, `53716`.
* Position it in a parallelogram, whose side length equals the number of digits of the number, and has two sides positioned diagonally, as shown below.
```
    53716
   53716
  53716
 53716
53716
```
* Now, we want to ‚àÜ it, right? To do so, crop the sides that do not fit into a right-angled triangle:
```
    5
   53
  537
 5371
53716
```
* Take the sums of each row, for this example resulting in `[5, 8, 15, 16, 22]`:
```
    5  -> 5
   53  -> 8
  537  -> 15
 5371  -> 16
53716  -> 22
```
* Sum the list `[5, 8, 15, 16, 22]`, resulting in `66`. This is the triangle of this number!
# Specs & Rules
* The input will be a non-negative integer *n* (*n ‚â• 0, n ‚àà Z*).
* You may take input and provide output by [any allowed mean](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).
* Input may be formatted as an integer, a string representation of the integer, or a list of digits.
* [Default loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) disallowed.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins!
# More Test Cases
```
Input -> Output
0 -> 0
1 -> 1
12 -> 4
123 -> 10
999 -> 54 
100000 -> 6
654321 -> 91
```
---
[*Inspiration.*](https://codegolf.stackexchange.com/questions/136564/square-a-number-my-way) Explanations are encouraged!
  
[Answer]
# [Haskell](https://www.haskell.org/), 13 bytes
```
sum.scanl1(+)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P822uDRXrzg5MS/HUENb839uYmaegq1CQVFmXomCikKaQrSZjqmOiY6xjpGOYex/AA "Haskell ‚Äì Try It Online")
Takes input as list of digits. Calculates the cumulative sums then sums them.
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~4Ã∑~~ 2 bytes
Thanks @H.PWiz for `-2` bytes!
```
Œ£‚à´
```
[Try it online!](https://tio.run/##yygtzv7//9ziRx2r////H22qY6xjrmOoYxYLAA "Husk ‚Äì Try It Online")
### "Ungolfed"/Explained
```
Œ£    -- sum all
 ‚à´   -- prefix sums
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~65, 50,~~ 36 bytes
```
([])({<{}>{<({}[()])>[]}{}<([])>}{})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/XyM6VlOj2qa61q7aRqO6NlpDM1bTLjq2trrWBiRlB2Ro/v9vqGCkYAwA "Brain-Flak ‚Äì Try It Online")
After lots of revising, I'm now very proud of this answer. I like the algorithm, and how nicely it can be expressed in brain-flak.
Most of the byte count comes from handling 0's in the input. In fact, if we could assume there were no 0's in the input, it would be a beautifully short 20-byte answer:
```
({{<({}[()])>[]}{}})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X6O62kajujZaQzNW0y46tra6tlbz/39DBSMFYwA "Brain-Flak ‚Äì Try It Online")
But unfortunately, brain-flak is notorious for bad handling of edge cases. 
# Explanation
First, an observation of mine:
If the input is *n* digits long, the first digit will appear in the triangle *n* times, the second digit will appear *n-1* times, and so on onto the last digit, which will appear once. We can take advantage of this, since it's really easy to calculate how many digits of input are left in brain-flak, namely
```
[]
```
So here's how the code works.
```
# Push the size of the input (to account for 0's)
([])
# Push...
(
    # While True
    {
        # Pop the stack height (evaluates to 0)
        <{}>
        # For each digit *D*...
        # While true
        {
            # Decrement the counter (the current digit we're evaluating), 
            # but evaluate to 0
            <({}[()])>
            # Evaluate the number of digits left in the input
            []
        # Endwhile
        }
        # This whole block evaluates to D * len(remaining_digits), but 
        # without affecting the stack
        # Since we looped D times, D is now 0 and there is one less digit.
        # Pop D (now 0)
        {}
        # Push the stack height (again, evaluating it as 0)
        <([])>
    # End while
    }
    # Pop a 0 off (handles edge case of 0)
    {}
# end push
)
```
[Answer]
# Pyth - ~~6~~ 4 bytes
```
ss._
```
[Try it online here](http://pyth.herokuapp.com/?code=ss._&input=5%2C3%2C7%2C1%2C6&debug=0).
Nice 6 byte one that doesn't use prefix builtin:
```
s*V_Sl
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 3 bytes
```
Yss
```
[Try it online!](https://tio.run/##y00syfn/P7K4@P//aFMdBWMdBXMdBUMdBbNYAA "MATL ‚Äì Try It Online")
Takes the input as a list of digits.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
+\S
```
[Try it online!](https://tio.run/##y0rNyan8/187Jvj////RZjqmOiY6xjpGOoaxAA "Jelly ‚Äì Try It Online") Uses the same technique as my Japt answer: cumulative addition, then sum.
[Answer]
# [Haskell](https://www.haskell.org/), 25 bytes
*Takes input as list of digits*
```
f[]=0
f x=sum x+f(init x)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/Py061taAK02hwra4NFehQjtNIzMvs0ShQvN/bmJmnm1BUWZeiUpatKmOsY65jqGOWex/AA "Haskell ‚Äì Try It Online")
# [Haskell](https://www.haskell.org/), 41 bytes
*Takes input as string representation*
```
f[]=0
f x=sum(map(read.(:[]))x)+f(init x)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/Py061taAK02hwra4NFcjN7FAoyg1MUVPwyo6VlOzQlM7TSMzL7NEoULzf25iZp5tQVFmXolKmpKpsbmhmdJ/AA "Haskell ‚Äì Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~7~~ ~~6~~ 4 bytes
```
√•+ x
```
[Try it online!](https://tio.run/##y0osKPn///BSbYWK//@jzXRMdUx0jHWMdAxjAQ "Japt ‚Äì Try It Online")
### Explanation
```
√•+ x    Implicit: input = digit list
√•+      Cumulative reduce by addition. Gives the sum of each prefix.
   x    Sum.
```
---
Old solution:
```
√•+ ¬¨¬¨x
```
[Try it online!](https://tio.run/##y0osKPn///BSbYVDaw6tqfj/X8nU2NzQTAkA "Japt ‚Äì Try It Online")
### Explanation
```
√•+ ¬¨¬¨x   Implicit: input = string
√•+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬¨     Join into a single string of digits.
    ¬¨    Split back into digits.
     x   Sum.
         Implicit: output result of last expression
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 28 bytes
```
(([]){[{}]({}<>{})<>([])}{})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X0MjOlazOrq6NlajutbGrrpW08YOJFQLZP3/b6hgpGAMAA "Brain-Flak ‚Äì Try It Online")
*14 bytes if we don't need to support zeros (which we do)*
```
({({}<>{})<>})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X6Nao7rWxq66VtPGrlbz/39DBSMFYwA "Brain-Flak ‚Äì Try It Online")
DJMcMayhem has a cool answer [here](https://codegolf.stackexchange.com/a/137651/56656) you should check out. Unfortunately for him I wasn't about to let him win at his own language :P
## How does it work?
Lets start with the simple version.
```
({({}<>{})<>})
```
The main action here is `({}<>{})<>`, that takes the top of the left stack and adds to to the top of the right stack. By looping this operation we sum up the current stack (until it hits a zero) placing the sum on the off stack. That's pretty mundane, the interesting part is that we sum up the results of all these runs as our result. This will calculate the desired value. Why? Well lets take a look at an example, `123`. On the first grab we just get 1 so our value is 1
```
1
```
On the next grab we return 1 plus the 2
```
1
1+2
```
On the last run we have all three together
```
1
1+2
1+2+3
```
Do you see the triangle? The sum of all the runs is the "triangle" of the list.
---
Ok but now we need it to work for zeros, here I used the same trick as DJMcMayhem, plus some fancy footwork. Instead of looping until we hit a zero we loop until the stack is empty.
```
([])({<{}>({}<>{})<><([])>}{})
```
I then used [this tip](https://codegolf.stackexchange.com/questions/95403/tips-for-golfing-in-brain-flak/127942#127942), written by none other than yours truly, to golf off another 2 bytes.
```
(([]){[{}]({}<>{})<>([])}{})
```
And there we have it. I would be surprised if there was a shorter solution, but then again stranger things have happened.
[Answer]
## JavaScript (ES6), 28 bytes
```
a=>a.map(d=>t+=c+=d,t=c=0)|t
```
Takes input as a list of digits.
[Answer]
# [Python 3](https://docs.python.org/3/), 37 bytes
```
f=lambda n:len(n)and sum(n)+f(n[:-1])
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P802JzE3KSVRIc8qJzVPI08zMS9Fobg0F8jSTtPIi7bSNYzV/F9QlJlXopGmEW2mY6pjomOsY6QDFNb8DwA "Python 3 ‚Äì Try It Online")
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 59 bytes
```
using System.Linq;N=>N.Reverse().Select((d,i)=>i*d+d).Sum()
```
[Try it online!](https://tio.run/##XZBBS8QwFITv@RXvmGgsu64KEtuL4En34B48LHuI6bMG2tc1SVck9LfX0LWyXQYC32QYHmP8lWkdDp23VMHmxwdsFDul7NnSl2KkG/R7bRAoMlNr72EfmQ86WANPHZkHS2G7k@ktIDirqaoR8mGdF@vsFQ/oPHKRbbBGEzgvpRV5YS/KyzKZXcPFoKa2Q2tLeNGWuIhsbN3uQLvKQw6E3/BnRfYPcdHLE1rOSV6fs1zNnHuZdJZZTJr5d/JW3shValj2rFeMfaTxtPnk4zdQ17yjS9nx3HT9Y0u@rTF7czZgGhL5NA0/ZoVQrD9q@AU "C# (.NET Core) ‚Äì Try It Online")
Substantially different from the other C# answers. Input is a list of digits. All test cases included in the TIO link.
Could save a bunch of bytes if allowed to take input as a backwards list of digits with leading 0.
[Answer]
# [Python 3](https://docs.python.org/3/), 35 bytes
I just noticed that this is only really a slight golf of [Business Cat's answer](https://codegolf.stackexchange.com/a/137654/53748) in the end though!
```
f=lambda a:a>[]and sum(a)+f(a[:-1])
```
**[Try it online!](https://tio.run/##NUxLCsIwFFzrKd6uCU6haW3FgL1IyOJJDRZsWtq48PQx8cPA/GBmeYX77JsY3eXB03VgYs29sewH2p6TYHlwgo0ulZXRzSuF2xZo9CRMiwYnKHQWZKpMCvVP0GRzRsK3qf7IsUOLY1rXSK96v1vW0QeRn0FF2Rcg90lSxjc "Python 3 ‚Äì Try It Online")**
[Answer]
# [J](http://jsoftware.com/), ~~7~~ 6 bytes
```
1#.+/\
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuo2CgYAXEunrOQTo@bv8NlfW09WP@a3KVJIPkDRSsFQzB2AhKGgNpSzAE8Q3g0FrBTMFUwQQob6RgyMWVmpyRr6BhaKCmrKegEa2jrqBrB7QsVlNNyUohTVPBwU4BaMF/AA "J ‚Äì Try It Online") Takes a list of digits, such as `f 6 5 4 3 2 1`.
## Explanation
The current explanation is same as the old, but noting that `1#.x` ‚áî `+/x` (both compute sum).
Old:
```
[:+/+/\    (for explanation, input = 6 5 4 3 2 1)
      \    over the prefixes of the input:
     /         reduce:
    +              addition (summation)
           this gives is the cumulative sum of the input:  6 11 15 18 20 21
[:         apply to the result:
  +/           summation
           this gives the desired result:   90
```
A little more true to the original problem would be `[:+/@,]/`, which is "sum" (`+/`) the flattened (`,`) prefixes of the input (`]\`).
[Answer]
# [Vim](https://vim.sourceforge.io/), ~~60~~ ~~59~~ 32 keystrokes
Thanks a lot @CowsQuack for the tip with the recursive macro and the `h` trick, this saved me 27 bytes!
```
qqYp$xh@qq@qVHJ:s/./&+/g‚èé
C<C-r>=<C-r>"0‚èé
```
[Try it online!](https://tio.run/##K/v/v7AwskClIsOhsNChMMzDy6pYX09fTVs/nctZyFZIyYDr/38zUxNjI0MA "V ‚Äì Try It Online")
### Ungolfed/Explained
This will build the triangle like described (only that it keeps it left-aligned):
```
qq       q    " record the macro q:
  Yp          "   duplicate the line
    $x        "   remove last character
      h       "   move to the left (this is solely that the recursive macro calls stop)
       @q     "   run the macro recursively
          @q  " run the macro
```
The buffer looks now like this:
```
53716
5371
537
53
5
```
Join all lines into one and build an evaluatable expression from it:
```
VH             " mark everything
  J            " join into one line
   :s/./&+/g‚èé  " insert a + between all the characters
```
The `"` register now contains the following string (note missing 0):
```
5+3+7+1+6+ +5+3+7+1+ +5+3+7+ +5+3+ +5+ +
```
So all we need to do is append a zero and evaluate it:
```
 C                " delete line and store in " register
  <C-r>=       ‚èé  " insert the evaluated expression from
        <C-r>"    " register "
              0   " append the missing 0
```
[![inside vim](https://i.stack.imgur.com/8YwON.gif)](https://i.stack.imgur.com/8YwON.gif)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~49~~ 45 bytes
*-4 bytes [thanks to Mr. Xcoder.](https://chat.stackexchange.com/transcript/message/39234534#39234534)*
```
lambda n:sum(-~i*n[~i]for i in range(len(n)))
```
[Try it online!](https://tio.run/##TU3NCsIwGLvvKXJs5RO2@QMKe5LaQ8VWC@u3sdaDl716tUVBCEkICZlf6TFxn91wyaMJ15sBn@MziO3qN6xWr920wMMzFsN3K0bLgqWUOdmYIgYo1WqC6ioR@p8SdsWeCAXftP1HyY6EA2H/KddJp3XTzIvnhGBm4Qj1RuY3 "Python 2 ‚Äì Try It Online")
Takes input as a list of digits.
[Answer]
# Bash + GNU utilities, 32 24
```
tac|nl -s*|paste -sd+|bc
```
Input read from STDIN.
Update: I see the input may be given as a list of digits. My input list is newline-delimited.
[Try it online](https://tio.run/##S0oszvj/vyQxuSYvR0G3WKumILG4JBXIStGuSUr@/9@Uy5jLnMuQy4wLAA).
### Explanation
```
tac                       # reverse digit list
   |nl -s*                # prefix line numbers; separate with "*" operator
          |paste -sd+     # join lines onto one line, separated with "+" operator
                     |bc  # arithmetically evaluate
```
[Answer]
# APL, 4 bytes
```
+/+\
```
This takes the input as a list of digits, e.g.:
```
      (+/+\) 5 3 7 1 6
66
```
Explanation
```
+/    sum of
  +\  partial sums of input
```
[Answer]
# [Taxi](https://bigzaphod.github.io/Taxi/), 1478 bytes
```
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Chop Suey.Go to Chop Suey:n 1 r 1 l 4 r 1 l.[a]Switch to plan "b" if no one is waiting.Pickup a passenger going to The Babelfishery.Go to Zoom Zoom:n 1 l 3 r.1 is waiting at Starchild Numerology.Go to Starchild Numerology:w 4 l 2 r.Pickup a passenger going to Addition Alley.Go to Addition Alley:w 1 r 3 r 1 r 1 r.Pickup a passenger going to Addition Alley.Go to The Babelfishery:n 1 r 1 r.Go to Chop Suey:n 6 r 1 l.Switch to plan "a".[b]Go to Addition Alley:n 1 l 2 l.Pickup a passenger going to Cyclone.[c]Go to Zoom Zoom:n 1 l 1 r.Go to Cyclone:w.Pickup a passenger going to The Underground.Pickup a passenger going to Multiplication Station.Go to The Babelfishery:s 1 l 2 r 1 r.Pickup a passenger going to Multiplication Station.Go to Multiplication Station:n 1 r 2 l.Pickup a passenger going to Addition Alley.Go to The Underground:n 2 l 1 r.Switch to plan "d" if no one is waiting.Pickup a passenger going to Cyclone.Go to Addition Alley:n 3 l 1 l.Switch to plan "c".[d]Go to Addition Alley:n 3 l 1 l.[e]Pickup a passenger going to Addition Alley.Go to Zoom Zoom:n 1 l 1 r.Go to Addition Alley:w 1 l 1 r.Pickup a passenger going to Addition Alley.Switch to plan "f" if no one is waiting.Switch to plan "e".[f]Go to Zoom Zoom:n 1 l 1 r.Go to Addition Alley:w 1 l 1 r.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.
```
[Try it online!](https://tio.run/##tZTNboMwDMdfxeIBkKBdD711O@y0rVK3yxCHNAkQLY1RCGJ9eha@Okb5UCvtABHE/tv@OY4h36IsnxEMwh4zA29RJCjfFuCBtI@uVncv6FeeAoGUZBlXMdcQo1Bx5fWUYAqHnJ/dRuXyvVWdP6xbnYCEh0IYmlSGqSQKnKMDIgKFgIqDyKAgwljl2ZDvCYdHcuQyElnCdRf5E/FUv@rIElagXa@nCcTAwRBNEyEZvOYnrlFi3LmPbVkOa6vkW6W5hHaM2QioYCflBcTfnzVRXeXUUrlDcVj3hbAeYb9pmQ@BE8cNjuFoig02f6nhZypts9yAhuPce/k0pttisZ0finEda8wVm7V9yaURqRSU1HnbnlXrFJ@sLWiZ96zu@GZLfwnXZCd7JVspvwU3bBe7Yz66Dk00eVWHuj4Z1J4MFi44BTy8udrpAzIyI/LW2RiWEU0QG9pxW24U/kuGExfUzPzOqfXuZff6pv5NuCw3D@uV7/0A "Taxi ‚Äì Try It Online")
Un-golfed:
```
[ Pickup stdin and split into digits ]
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to Chop Suey.
Go to Chop Suey: north 1st right 1st left 4th right 1st left.
[a]
[ Count the digits ]
Switch to plan "b" if no one is waiting.
Pickup a passenger going to The Babelfishery.
Go to Zoom Zoom: north 1st left 3rd right.
1 is waiting at Starchild Numerology.
Go to Starchild Numerology: west 4th left 2nd right.
Pickup a passenger going to Addition Alley.
Go to Addition Alley: west 1st right 3rd right 1st right 1st right.
Pickup a passenger going to Addition Alley.
Go to The Babelfishery: north 1st right 1st right.
Go to Chop Suey: north 6th right 1st left.
Switch to plan "a".
[b]
Go to Addition Alley: north 1st left 2nd left.
Pickup a passenger going to Cyclone.
[c]
[ Multiply each digits by Len(stdin)-Position(digit) ]
Go to Zoom Zoom: north 1st left 1st right.
Go to Cyclone: west.
Pickup a passenger going to The Underground.
Pickup a passenger going to Multiplication Station.
Go to The Babelfishery: south 1st left 2nd right 1st right.
Pickup a passenger going to Multiplication Station.
Go to Multiplication Station: north 1st right 2nd left.
Pickup a passenger going to Addition Alley.
Go to The Underground: north 2nd left 1st right.
Switch to plan "d" if no one is waiting.
Pickup a passenger going to Cyclone.
Go to Addition Alley: north 3rd left 1st left.
Switch to plan "c".
[d]
Go to Addition Alley: north 3rd left 1st left.
[e]
[ Sum all the products ]
Pickup a passenger going to Addition Alley.
Go to Zoom Zoom: north 1st left 1st right.
Go to Addition Alley: west 1st left 1st right.
Pickup a passenger going to Addition Alley.
Switch to plan "f" if no one is waiting.
Switch to plan "e".
[f]
[ Output the results ]
Go to Zoom Zoom: north 1st left 1st right.
Go to Addition Alley: west 1st left 1st right.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: north 1st right 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.
```
[Answer]
# [Perl 5](https://www.perl.org/), 19 + 1 (`-p`) = 20 bytes
```
s/./$\+=$p+=$&/ge}{
```
[Try it online!](https://tio.run/##K0gtyjH9/79YX09fJUbbVqUAiNX001Nrq///NzM1MTYy/JdfUJKZn1f8X9fXVM/A0OC/bgEA "Perl 5 ‚Äì Try It Online")
**How?**
$\ holds the cumulative total, $p holds the total of the digits on the current line. Each line of the parallelogram is simply the previous line with the next digit of the number appended. Therefore, it is the sum of the previous line plus the new digit. This iterates over all of the digits, calculating the sums as it goes. The actual substitution is irrelevant; it's just a means to iterate over the digits without creating an actual loop. At the end, $\ is printed implicitly by the `-p` option.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 20 bytes
Takes the input as a list of digits.
```
a->a*Colrev([1..#a])
```
[Try it online!](https://tio.run/##K0gsytRNL/ifpmCr8D9R1y5Ryzk/pyi1TCPaUE9POTFW839iQUFOpUaigq6dQkFRZl4JkKkE4igppGkkamrqKERHm@ooGOsomOsoGOoomMUCRUDYEEzoKBjBaKAiENNSRwGEoKIGyAgkZqajADTOBGwiUIthLNAJAA "Pari/GP ‚Äì Try It Online")
---
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 15 bytes
Takes the input as a polynomial. For example, `5*x^4 + 3*x^3 + 7*x^2 + x + 6` means `53716`.
```
a->(a+a')%(x-1)
```
[Try it online!](https://tio.run/##TYzBCsIwEER/ZSiISbsBkzSVHOyPiMJeKgWRUDzEr4@bUMHD8nZmdifxtppHKgsuKGxmxQMf9UFlY3XhlJ4fxTAz0ra@3rJ2VXRYFGtNuIY@30cM8EIvPAudMMtMhBPBUhNO0BLXV@kJcT@NzYg1D4RJ3CD6Vzzuxb7/f7c3Xb4 "Pari/GP ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 56 bytes
```
lambda x:sum(i*int(`x`[-i])for i in range(1,1+len(`x`)))
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCqrg0VyNTKzOvRCOhIiFaNzNWMy2/SCFTITNPoSgxLz1Vw1DHUDsnNQ8kramp@R8uG22gA5QyAiJjHUtLSx1DAxDQMTM1MTYyjLXiUigoApqqkKmjrmunrpOmkan5HwA "Python 2 ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~5~~ 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
·πö√¶.J
```
A monadic link taking a list of decimal digits and returning the triangle of the number that list represents.
**[Try it online!](https://tio.run/##y0rNyan8///hzlmHl@l5/f//P9pQxwAGYwE "Jelly ‚Äì Try It Online")**
### How?
```
·πö√¶.J - Link: list of numbers (the decimal digits), d   e.g. [9,4,5,0]
·πö    - reverse d                                            [0,5,4,9]
   J - range(length(d))                                     [1,2,3,4]
 √¶.  - dot-product            (0*1 + 5*2 + 4*3 + 9*4 = 58)  58
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 13 bytes
```
.
$`$&
.
$*
1
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wX49LJUFFjQtIaXEZ/v9vamxuaMZlwGXIZWgERMZclpaWXIYGIMBlZmpibGQIAA "Retina ‚Äì Try It Online") Link includes test cases. Explanation: The first stage generates all the prefixes of the original number, the second stage converts each digit to unary, and the third stage takes the total.
[Answer]
# Mathematica, 49 bytes
```
Tr@Array[Tr@s[[;;#]]&,Length[s=IntegerDigits@#]]&
```
[Answer]
# [Neim](https://github.com/okx-code/Neim), 3 bytes
```
ùêóùêÇùê¨
```
Explanation:
```
ùêó        Get prefixes of input, including itself
 ùêÇ       Implicitly join elements together, and create an array with all the digits
  ùê¨      Sum
```
[Try it online!](https://tio.run/##y0vNzP3//8PcCdOBuAmI1/z/b2psbmgGAA "Neim ‚Äì Try It Online")
Alternative answer:
```
ùêóùê£ùê¨
```
Explanation:
```
ùêó       Get prefixes of input, including itself
 ùê£       Join
  ùê¨      Implicitly convert to a digit array, and sum
```
[Try it online!](https://tio.run/##y0vNzP3//8PcCdOBeDEQr/n/39TY3NAMAA "Neim ‚Äì Try It Online")
[Answer]
# Java 8, 53 bytes
I implemented a lambda for each acceptable input type. They each iterate through the number's digits, adding the proper multiple of each to an accumulator.
## Integer as input (53 bytes)
Lambda from `Integer` to `Integer`:
```
n->{int s=0,i=1;for(;n>0;n/=10)s+=n%10*i++;return s;}
```
## String representation as input (72 bytes)
Lambda from `String` to `Integer`:
```
s->{int l=s.length(),n=0;for(int b:s.getBytes())n+=(b-48)*l--;return n;}
```
## Digit array as input (54 bytes)
Lambda from `int[]` (of digits, largest place value first) to `Integer`:
```
a->{int l=a.length,s=0;for(int n:a)s+=n*l--;return s;}
```
* -7 bytes thanks to Olivier Gr√©goire
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), ~~9~~ 6 [bytes](https://github.com/mudkip201/pyt/wiki/Codepage)
```
ƒÖƒê≈Å≈ô‚Üî¬∑
```
Explanation:
```
                 Implicit input
ƒÖ                Convert to array of digits
 ƒê               Duplicate digit array
   ≈Å≈ô‚Üî           Create a new array [len(array),len(array)-1,...,1]
      ¬∑          Dot product with digit array
                 Implicit output
```
[Answer]
## **Python 3,  ~~94~~  ~~58~~  54 bytes**
Thanks to [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder) for helping me save quite some bytes!
```
lambda n:sum(int(v)*(len(n)-i)for i,v in enumerate(n))
```
[Try It Online!](https://tio.run/##K6gsycjPM9ZNBtP/S2xj/uck5ialJCrkWRWX5mpk5pVolGlqaeSk5mnkaepmaqblFylk6pQpZOYppOaV5qYWJZakAmU0/xcUgdSWaCiZmZoYGxkqAYUA)
Takes input as a string. It simply multiplies each digit by the number of times it needs to be added and returns their sum.
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 79 bytes
```
	N =INPUT
D	N LEN(1) . D REM . N	:F(O)
	X =X + D
	Y =Y + X	:(D)
O	OUTPUT =Y
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/n9NPwdbTLyA0hMsFyPRx9dMw1FTQU3BRCHL1BdJ@nFZuGv6aXJwRCrYRCtoKLlyckQq2kUBWBKeVhosmlz@nf2gIUDtQkMvVz@X/f1Njc0MzAA "SNOBOL4 (CSNOBOL4) ‚Äì Try It Online")
Input from stdin, output to stdout.
]