[Question]
  [
Given a digit `x` (between 0 to 9, inclusive) and a number `n`, calculate the sum of the first `n` terms of the following sequence:
\$x,10x+x,100x+10x+x,\dots\$
For example, if `x` is 6 and `n` is 2, then the result will be `6+66` meaning 72.
There can be trailing whitespace in the output but not leading whitespace.
  
[Answer]
# [Python 2](https://docs.python.org/2/), 28 bytes
```
lambda x,n:(10**-~n/9-n)/9*x
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaFCJ89Kw9BAS0u3Lk/fUjdPU99Sq@J/QVFmXolGmoaZjpGmjoKZgraCmZkmF0LUGC4KJlDkTNDkIKSZ5n8A "Python 2 – Try It Online")
-6 thanks to @Bubbler and @tsh
Aha the first answer I have used some math
**How?**
Let's call \$n^{th}\$ term as \$y\$
$$
S\_n=x+(10x+x)+(100x+10x+x)+.....+y\\= x+(11x)+(111x)+.....+y\\=\frac{x}{9}(9+99+999+.....+y)\\=\frac{x}{9}((10-1)+(100-1)+(1000-1)+.....+y)\\=\frac{x}{9}((10+100+1000+.....+y)-(1+1+1+.....+1))\\=\frac{x}{9}((10^1+10^2+10^3+...+y)-n)\\=\frac{x}{9}(\frac{10(10^n-1)}{10 - 1}-n)\\=\frac{x}{9}(\frac{10(10^n-1)-9n}{9})\\=\frac{x(10(10^n-1)-9n)}{81}
$$
And we get our magic formula!
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
RḌ×
```
[Try it online!](https://tio.run/##y0rNyan8/z/o4Y6ew9P///9v8t8MAA "Jelly – Try It Online")
```
RḌ×    Dyadic link; left arg = n, right arg = x
R      [1..n]
 Ḍ     Undecimal, which is the same as 1 + 11 + ... + (n copies of 1)
  ×    Multiply x
```
---
These are the "backports" of the same algorithm into J and APL:
# [J](http://jsoftware.com/), 9 bytes
```
*10#.1+i.
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqNgoGAFxLp6Cs5BPm7/tQwNlPUMtTP1/mtycaUmZ@QrmCmkKZj8BwA "J – Try It Online")
`1+` is needed because J does not have 1-based range built-in.
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 6 bytes
```
10⊥×∘⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///39DgUdfSw9Mfdcx41Lv5f9qjtgmPevsedTUfWm/8qG3io76pwUHOQDLEwzP4v5lCmoIJAA "APL (Dyalog Unicode) – Try It Online")
*-1 byte thanks to @ovs*
Uses a slightly different algorithm for golfing purposes: multiply `x` to `1..n`, and then evaluate as base 10. This version of the algorithm works in Jelly too: `R×Ḍ`. [Try it online!](https://tio.run/##y0rNyan8/z/o8PSHO3r@//9v8t8MAA)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 24 bytes
```
t=>g=n=>n&&t*n+10*g(n-1)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/E1i7dNs/WLk9NrUQrT9vQQCtdI0/XUPN/cn5ecX5Oql5OfrpGmoaZpoaRpiYXqqChpoalpuZ/AA "JavaScript (Node.js) – Try It Online")
$$ f(n,x)=\sum\_{i=1}^n 10^{n-i}\cdot i\cdot x $$
$$ f(n,x)=nx+10\cdot f(n-1,x) \\ f(0,x)=0 $$
For example, we have:
\$f(6,3)\\
=6+66+666\\
=6+(60+6)+(600+60+6)\\
=600×1+60×2+6×3\\
=((6×1)×10+6×2)×10+6×3\\
=10\cdot f(6,2)+6×3\$
[Answer]
# [Excel](https://www.microsoft.com/en-us/microsoft-365/excel), 29 bytes
```
=SUM(--REPT(A1,SEQUENCE(A2)))
```
`x` is input in `A1` and `n` is input in `A2`. The formula goes anywhere else in the same sheet.
`SEQUENCE(A2)` creates an array of all the values from 1 to `n`.  
`REPT(A1,~)` creates an array of strings of `x` repeated an increasing number of times based on the array created from the previous step.  
`--REPT(~)` turns those strings into numbers.  
`SUM(~)` adds up those numbers.
[![Screenshot](https://i.stack.imgur.com/JKiyY.png)](https://i.stack.imgur.com/JKiyY.png)
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `R`, ~~3~~ 2 bytes
```
I*
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=R&code=I*&inputs=4%0A6&header=&footer=)
*Thanks to @AaronMiller for -1*
## 3 bytes, `-rs`
```
ƛ⁰ẋ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=rs&code=%C6%9B%E2%81%B0%E1%BA%8B&inputs=2%0A6&header=&footer=)
;)
## Explained
```
ƛ⁰ẋ
ƛ       # For each number n in the range [1, N]:
 ⁰ẋ     #  return x repeated n times (`-r` makes elements take arguments in reverse order)
        # The `-s` flag sums the top of the stack before outputting
```
## 4 bytes, `s` flag
```
ɾ?vẋ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=s&code=%C9%BE%3Fv%E1%BA%8B&inputs=2%0A6&header=&footer=)
## 5 bytes, flagless
```
ɾ?vẋ∑
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C9%BE%3Fv%E1%BA%8B%E2%88%91&inputs=2%0A6&header=&footer=)
[Answer]
# [J](http://jsoftware.com/), 11 8 bytes
```
1#.".\@$
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DZX1lPRiHFT@a3KlJmfkKxgppCmom6lDOMYQzn8A "J – Try It Online")
Assuming I can take the digit as a string...
Taking `3 f '6'` as an example:
* `$` - Duplicate:
```
'666'
```
* `".\` Evaluate each prefix:
```
6 66 666
```
* `1#.` Sum
```
738
```
[Answer]
# MATLAB/Octave, ~~28~~ 26 bytes
*-2 bytes thanks to Giuseppe*
```
@(x,n)(1:n)*.1.^(1-n:0)'*x
```
[Try it online!](https://tio.run/##TYpbCoAgEEX/20gzjkn2ECyEVhJI1KdBRrh70yLoMnPhcM@@nPZaY5wgcIcgB4dMSDGDrNxQY8lC3Ix1fiw2ULzBwnq/Hie8ZAwoRQoxrS3vf2umtLY59BXle2TNu5@cKck6hd4njRhv "Octave – Try It Online")  
Anonymous function.
**How it works**  
First of all, sum $$x + (10x + x) + (100x + 10x + x) + ... + (10^{n-1}x + 10^{n-2}x + ... 10x + x)$$
can be transformed to:
$$ n\cdot x + 10(n-1)\cdot x + 100(n-2) \cdot x + ... +10^{n-2} \cdot 2 x + 10^{n-1} x $$
which is:
$$ x \cdot \sum\_{i=0}^{n-1}(n-i) 10^i = 
x \cdot \sum\_{i=0}^{n-1}(n-i)\cdot{0.1^{-i}}$$
Having that established:
* `1:n` is vector containing elements ![(n-1)](https://chart.googleapis.com/chart?cht=tx&chl=(n-i)), but in reverse order of indexing than above
* `1-n:0` are just indexes of sum above but reversed and negates (so ![-(n-1), -(n-2), ..., -1, 0](https://chart.googleapis.com/chart?cht=tx&chl=%5B-(n-1)%2C-(n-2)%2C...%2C-1%2C0%5D))
* `.1.^(1-n:0)` is then vector containing elements ![0.1^(-i)](https://chart.googleapis.com/chart?cht=tx&chl=0.1%5E%7B-i%7D) in reversed order of indexing
To get the sum straightforward we would multiply elements of vectors element by element and then sum them like so (whitespace added for readability):
```
sum(  (1:n)  .*   (.1.^(1-n:0))   )
```
However, knowing how matrix multiplication works we can just transpose second vector and by multiplying the matrices:
```
(1:n)  *  (.1.^(1-n:0))'
```
we will get exactly the same result. And at the end we just multiply everything by `x`.
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), 41 bytes
```
param($x,$n)iex "$(1..$n|%{"+";"$x"*$_})"
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNydFNzi9K/a@SZlv9vyCxKDFXQ6VCRyVPMzO1QkFJRcNQT08lr0a1WklbyVpJpUJJSyW@VlPpfy0Xl5pKmoKZgtF/AA "PowerShell Core – Try It Online")
## Explanations
```
iex "$(...)"          # Run as a command the result of the list below, joined using spaces
1..$n|%{"+";"$x"*$_}  # From 1 to n, build a list containing +,x,+,xx,+,xxx,+,xxxx,...
```
[Answer]
# [R](https://www.r-project.org/), ~~34~~ 32 bytes
```
function(d,n)sum(10^(1:n)-1)*d/9
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jRSdPs7g0V8PQIE7D0CpPU9dQUytF3/J/WGpySX5RZlWqRpqmhpmOoZWp5n8A "R – Try It Online")
$$
x + (10x + x) + (100x + 10x + x) + \ldots = \\
x + 11x + 111x + \ldots = \\
(9x + 99x + 999x + \ldots)/9 = \\
(9+99+999+\ldots)\*x/9 = \\
((10-1)+(100-1)+(1000-1)+\ldots)\*x/9 = \\
\big[\sum\_{i=1}^n(10^i-1)\big]\*x/9
$$
*-2 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)*
---
Using [@Wasif's formula](https://codegolf.stackexchange.com/a/225780/55372):
### [R](https://www.r-project.org/), 34 bytes
```
function(d,n)d*(10*(10^n-1)/9-n)/9
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jRSdPM0VLw9AAhOPydA019S1184DE/zQNMx0jzf8A "R – Try It Online")
---
Straightforward approach with strings:
### [R](https://www.r-project.org/), ~~43~~ 39 bytes
```
function(d,n)sum(strtoi(strrep(d,1:n)))
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jRSdPs7g0V6O4pKgkPxNEFaUWAEUNrfI0NTX/h6Uml@QXZValaqRpapgBRU01/wMA "R – Try It Online")
*-4 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)*
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
ẋḌƤS
```
[Try it online!](https://tio.run/##y0rNyan8///hru6HO3qOLQn@//@/2X8TAA "Jelly – Try It Online")
## Explanation
```
ẋ     repeat `x` `n` times
  Ƥ   for each prefix
 Ḍ    convert it from digits to a decimal number
   S  and sum
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 bytes
```
*dḣ
```
[Try it online!](https://tio.run/##yygtzv7/Xyvl4Y7F////N/pvBgA "Husk – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), [Python 2](https://docs.python.org/2/), 28 bytes
```
lambda x,n:(10**n/.9-n)//9*x
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaFCJ89Kw9BASytPX89SN09TX99Sq@J/QVFmXolGmoaZjpGmjoKZgraCmZkmF0LUGC4KJlDkTNDkIKSZ5n8A "Python 3 – Try It Online")
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaFCJ89Kw9BASytPX89SN09TX99Sq@J/QVFmXolGmoaZjpGmjoKZgraCmZkmF0LUGC4KJlDkTNDkIKSZ5n8A "Python 2 – Try It Online")
Unfortunately I cannot add comments so I'm reposting [Wasif's solution](https://codegolf.stackexchange.com/a/225780) with a small tweak so that it works in both python versions. While at it, also correct the math.
$$
S\_n=x+(10x+x)+(100x+10x+x)+...+y\\= x+(11x)+(111x)+...+y\\=\frac{x}{9}(9+99+999+...+\frac{9y}{x})\\=\frac{x}{9}((10-1)+(100-1)+(1000-1)+...+(\frac{9y}{x}+1-1))\\=\frac{x}{9}((10+100+1000+...+(\frac{9y}{x}+1))-(1+1+1+...+1))\\=\frac{x}{9}((10^1+10^2+10^3+...+10^n)-n)\\=\frac{x}{9}(\frac{10^{n+1}-10}{9}-n)\\=\frac{x}{9}(\frac{10(10^n-1)-9n}{9})\\=\frac{x(10(10^n-1)-9n)}{81}
$$
[Answer]
# [R](https://www.r-project.org/), 31 bytes
```
function(d,n)10^(1:n-1)%*%n:1*d
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jRSdP09AgTsPQKk/XUFNVSzXPylAr5X9YanJJflFmVapGmqaGmY6hlanmfwA "R – Try It Online")
Ports [elementiro's answer](https://codegolf.stackexchange.com/a/225816/67312).
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 28 [17 bytes](https://tio.run/##K0gtyjH7n1upoJamYKvwX0tBS8NQIaIiTkvbUFOvuDT3vzVXcWKlQpqGmY6R5n8A "Perl 6 – Try It Online")
```
* *(1 Xx^*+1).sum
```
Golfed by [Jo King](https://codegolf.stackexchange.com/users/76162/jo-king) from 28 byte solution:
* Positional arguments `$^a`, `$^b` replaced by whatever-stars
* `Xx` cross metaoperator responsible for generating `1, 11, 111...`
---
### Original, [28 bytes](https://tio.run/##K0gtyjH7/786WjtWQUMlLulRwzJDzSgtIDNRR0tBy9AAKKClWathpmOkqVecWPn/PwA "Perl 6 – Try It Online")
```
{$^a*(^$^b+1).map(1 x*).sum}
```
**Explanation**
* `$^a` is `x`, `$^b` is `n`
* `^$^b+1` is shorthand for `0..^$^b+1`, equivalent to `1..$^b`
* `.map(1 x*)` generates `1, 11, 111...`
* `.sum` adds the `n`-long sequence: 1 for `n=1`, 12, 123, etc.
---
### Alternative, [32 bytes](https://tio.run/##K0gtyjH7/79aJS5RSyNOJS5J21BTLzexQMNQoUJLU6@4NLdWw9BUxwjITKz8/x8A "Perl 6 – Try It Online")
```
{[+] ($^b…1)Z*($^a,* *10…*)}
```
**Explanation**
* `Z*` zip-multiplies two lists, based on the observation that
	+ `1E0` appears `n` times
	+ `1E1` appears `n-1` times
	+ `1E2` appears `n-2` times, etc.
[Answer]
# [Python 3](https://docs.python.org/3/), 43 bytes
```
lambda x,n:sum(int(x*-~i)for i in range(n))
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaFCJ8@quDRXIzOvRKNCS7cuUzMtv0ghUyEzT6EoMS89VSNPU/N/QRFIOk1D3UxdR8EEKAAA "Python 3 – Try It Online")
Accepts `x` as a string and `n` as an integer. If that's not acceptable, just use `lambda x,n:sum(int(`x`*-~i)for i in range(n))` in Python 2 for +2 (+5 with `str(x)` in Python 3).
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 26 bytes
```
{for(;$2--;b+=a)a=a$1}$0=b
```
[Try it online!](https://tio.run/##SyzP/v@/Oi2/SMNaxUhX1zpJ2zZRM9E2UcWwVsXANun/fzMFYwA "AWK – Try It Online")
I had an alternate algorithm I thought might be interesting, but it the code was longer... So this is pretty much a direct translation of the steps in the challenge description.
```
{for(;$2--;    )     }
```
Fir every line of input, the code runs the loop the number of times given by the second input parameter, the `n` value.
```
                a=a$1
```
The body of the loop appends another copy of the first input parameter to the requested digit, meaning the `x` value.
```
           b+=a
```
At the end of each iteration, the accumulator variable `b` is incremented by the current value of the digits placeholder.
```
                      $0=b
```
Finally, once the processing is done, `$0=b` overwrites the input line to display the accumulator value.
The only "trick" here is relying on the way AWK will happily treat variables as both strings and integers. Meaning, you can append digits together and still do mathematical operations using the results.
[Answer]
# [Perl 5](https://www.perl.org/) `-pal`, 22 bytes
```
map$\+="@F"x$_,1..<>}{
```
[Try it online!](https://tio.run/##K0gtyjH9/z83sUAlRttWycFNqUIlXsdQT8/Grrb6/38zLuN/@QUlmfl5xf91CxIB "Perl 5 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 24 bytes
```
n#x=x*div(10*10^n-9*n)81
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P0@5wrZCKyWzTMPQQMvQIC5P11IrT9PC8H9uYmaebUFRZl6JipGy2X8A "Haskell – Try It Online")
Uses [Wasif's formula](https://codegolf.stackexchange.com/a/225780/82619).
## [Haskell](https://www.haskell.org/), also 24 bytes
```
0#x=0
n#x=n*x+10*(n-1)#x
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/30C5wtaAKw9I5mlVaBsaaGnk6RpqKlf8z03MzLMtKMrMK1ExUjb7DwA "Haskell – Try It Online")
A port of [tsh's excellent recursive formula](https://codegolf.stackexchange.com/a/225781/82619).
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-x`](https://codegolf.meta.stackexchange.com/a/14339/), 3 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Takes input in reverse order.
```
õçV
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LXg&code=9edW&input=NAo2)
```
õçV     :Implicit input of integers U=n & V=x
õ       :Range [1,U]
 çV     :  For each, repeat V that many times
        :Implicit output of sum of resulting array
```
[Answer]
# [Factor](https://factorcode.org/) + `math.unicode`, 44 bytes
```
[ [1,b] [ 10^ 1 - swap 9 / * ] with map Σ ]
```
[Try it online!](https://tio.run/##VY5BCsIwFET3PcWsRatVFFRwK27ciKtQIcZfDbVJTVKKlJ7G@3ilGGkR/Ks3b/gwGRdOG3887PbbFbi1WlgU3N1iw9WVes4qJZzUqovIySi6d1WlpNAXQmnIuWdppHKw9KhIifC9jpoI4RosMEXbc4L5j2d/PpmE0HoGlgzPKVgQp6BHsDUvscQYA6SoZRhRBPF@IfUN2m745qus4yKP/Qc "Factor – Try It Online")
Using the first thing that came to mind,
$$ f(x,n)=\sum\_{i=1}^n \frac{x}{9}(10^{i} - 1) $$
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/index.html), ~~20~~ 21 bytes
```
~:x;0\),(;{'1'*~x*+}%
```
[Try It Online!](https://tio.run/##S8/PSStOLsosKPn/31jB1KrC2iBGU0fDulrdUF2rrkJLu1b1/38A)
takes as input a string containing n and x, in that order
### Explanation
```
~:x;0\),(;{'1'*~x*+}%
~                      // parse the input string given
 :x;                   // bind the top value to the x variable
    0\                 // place a zero at the bottom of the stack
      ),(;             // create a list of numbers [1..n]
          {            // begin code block
           '1'*~       // create and evaluate a string of '1's to get the numbers 1, 11, 111...
                x*+    // multiply by x and add to the total (the zero we added)
                   }%  // execute this over every value in the list
                       // implicitly print the stack 
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~45~~ 43 bytes
Saved 2 bytes thanks to [Olivier Grégoire](https://codegolf.stackexchange.com/users/16236/olivier-gr%c3%a9goire)!!!
```
t;s;f(x,n){for(s=t=0;n--;)s+=t=t*10+x;n=s;}
```
[Try it online!](https://tio.run/##bVHtaoMwFP3vU1wEwY/IbJ0tJXN/xp5iypAYO9mWFhNYmPjqczc1ulomeHI959yPXFl8ZGwcFZW08TURQd@cOl/mKk@oiGMayAhjFW6SSFORSzqMrVDwWbXCD5zeAXwMobhUr/qlhBz6A4EdgYzAnkA60LVHTJ4NgS2qBO7ReeXh@syZ4vVfJYhgZ8rhmU1gKmOwn8Ci6YVROoHF@ZinYG9VFyJy9s47bAGmiVvo522hD0/4Zi6B6@/UtZm4FfDNgK2ouca0hNrwAWT7zU@NP48e3FkiXBgKUXRxBzCtbL6uqWRXd9FLupLFLIt/ZYny9NfWPEd@WeRt4rlDS@O7Xk3AqyF@NOjJQuDVNQFBQJJlRTzPZWmrD84w/rDmozrKMf76BQ "C (gcc) – Try It Online")
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 83 bytes
```
(a,b)=>Enumerable.Range(1,b).Sum(x=>Enumerable.Range(0,x).Sum(y=>a*Math.Pow(10,y)))
```
[Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpdsk5JfmpSTqpOZV6IDYdoppCnY/tdI1EnStLVzzSvNTS1KBArrBSXmpadqGAKF9YJLczUqsEga6FRAJCtt7RK1fBNLMvQC8ss1DA10KjU1Nf9bcznn5xXnA5WHF2WWpPpk5qVqpGmY6SgYamrilDPCI2cMlPsPAA "C# (Visual C# Interactive Compiler) – Try It Online")
# 39 bytes using @Wasif's formula
```
(a,b)=>a*(10*(Math.Pow(10,b)-1)-9*b)/81
```
[Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpdsk5JfmpSTqpOZV6IDYdoppCnY/tdI1EnStLVL1NIwNNDS8E0sydALyC8HcoDCuoaaupZaSZr6Fob/rbmc8/OK83NS9cKLMktSfTLzUjXSNMx0FAw1NXHKGeGRMwbK/QcA "C# (Visual C# Interactive Compiler) – Try It Online")
# 28 bytes using @tsh's formula
```
(a,b)=>b>0?a*b+10*f(a,b-1):0
```
[Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpdsk5JfmpSTqpOZV6IDYdoppCnY/tdI1EnStLVLsjOwT9RK0jY00EoDCekaaloZ/Lfmcs7PK87PSdULL8osSfXJzEvVSNMw01Ew1NTEKWeER84YKPcfAA "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Zsh](https://www.zsh.org/), 31 bytes
```
for ((;i++<$2;t+=a))a+=$1
<<<$t
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwYKlpSVpuhb70_KLFDQ0rDO1tW1UjKxLtG0TNTUTtW1VDLlsbGxUSiCqoIqXRZvpKBjFQnkA)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
L×O
```
[Try it online!](https://tio.run/##yy9OTMpM/f/f5/B0////TbjMAA "05AB1E – Try It Online")
```
L       -- list [1..input]
 ×      -- string multiply with input
  O     -- sum
```
[Answer]
# [Red](http://www.red-lang.org), 47 bytes
```
func[x n][t: s: 0 loop n[t: t + s: s * 10 + x]]
```
[Try it online!](https://tio.run/##K0pN@R@UmhIdy5Vm9T@tNC85ukIhLza6xEqh2ErBQCEnP79AIQ/ELVHQBgkVK2gpGBoA2RWxsf@LUgtSE0sU8hTMowuKMvNKos2AbCVdOyWFNAUgE6gCAA "Red – Try It Online")
## Alternative, 55 bytes
```
func[x n][t: copy""s: 0 loop n[s: s + to 1 append t x]]
```
[Try it online!](https://tio.run/##DcoxCoAwDAXQ3VN8uoqgi0IHD@EaOohNQZA01Ah6@trtDa9wrBtHCl3yNT1y0AsJZB5H1s@522PElbNCqPlGD8uYsKuyRBjeEGph5d0gWEjLKUZzsxtWh4TGNn4 "Red – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 20 bytes
```
.+(.)
*$1
L$v`.+
*
_
```
[Try it online!](https://tio.run/##K0otycxLNPyvquGe8F9PW0NPk0tLxZDLR6UsQU@bS4sr/v9/Ix1zLmMdUy4THWMuUx1DAA "Retina – Try It Online") Link includes test cases. Takes `n` as the first input. Note: Struggles for large values of `n` (`5` is just about doable). Explanation:
```
.+(.)
*$1
```
Generate `n` copies of `x`.
```
L$v`.+
*
```
Convert each suffix to unary.
```
_
```
Take the sum and convert to decimal.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 8 bytes
```
$+YaX\,b
```
[Try it online!](https://tio.run/##K8gs@P9fRTsyMSJGJ@n///9m/40A "Pip – Try It Online")
### Explanation
```
          a & b are command-line args (implicit)
   aX     String-multiply the digit by each number in...
     \,b  inclusive range from 1 through the number of terms
  Y       Yank (to enforce desired precedence)
$+        Fold on addition
          Autoprint (implicit)
```
[Answer]
# [Java (JDK)](http://jdk.java.net/), 53 bytes
```
x->n->{int r=0,y=0;for(;n-->0;)r+=y=y*10+x;return r;}
```
[Try it online!](https://tio.run/##VVLLiqNAFN3nKw5CQDulaJ4Q2wyzGRiGmSyaWYUsaqI2pk0pVWVQgt@euT7bBjn3es59VB3qyu/cvoYfz@SWZ1LjSv9OoZPUiQtx0UkmnBd/dkm5UvjNE4HHDMiLf2lygdJcU7hnSYgbaeablol4P53B5buy2lLgp9A/@lGvlP8VXFbHPJJcZ/KAGMGztA/CPjwSoSEDl1WB68eZNH1h2wfXt@QiqILqxXMXpS8jXUgB6ddPv51OTaczbdSR0gpBvxN4YMfgMexQs5HaMiwZtlhgu53yG4YVw4b4TQebqbpm7UfCuoMe19Oipp@mkLLqoMchrKbFzSHoKCQtO@hxCGNcTrua29CdSPM66HEIY/xMPNRte92ZRa7CvHPZurXvPLNGyxr/S7KwoU/u2Z/QYqC9L3RU5tFFR@GgLr@oMlJFqkmLHZ7naWWWVpd8V/QOTGENxW@V0tHNyQrt5PSAdGwaZTAPGQThHvNdiLmaC4OhJI71g9m4IPg8yDcYx18G9jD@HI1@QWNBPauf/wE "Java (JDK) – Try It Online")
[Answer]
# [Desmos](https://desmos.com/calculator), ~~30~~ ~~26~~ 25 bytes
```
f(x,n)=x(10^n10-10-9n)/81
```
[Try It On Desmos!](https://www.desmos.com/calculator/2wxk4lkb1c)
[Try It On Desmos!(Prettified)](https://www.desmos.com/calculator/gm7samiotk)
]