g | x | w | all
Bytes Lang Time Link
015APLNARS250905T180026ZRosario
015Dyalog APL250903T210322ZAaron
009cQuents250902T203838ZStephen
007Vyxal 3250902T144433ZThemooni
036AWK250902T140958Zxrs
032Juby230721T152527ZJordan
003Thunno 2 JL230721T061915ZThe Thon
050Excel VBA170923T181114ZTaylor R
029Retina171025T144553ZMartin E
073Ruby170924T072906ZEJAg
044Bash170926T152127ZNahuel F
031Röda171008T121119Zfergusq
093Powershell171008T104348ZAlly Wil
020[Dyalog APL]170923T123452Zdzaima
007Ohm v2171005T073214ZCinaski
111PocoLithp171005T060801ZAndrakis
014Charcoal170923T193348ZNeil
007Jelly170928T003720Zsporkl
044Scala170927T184105Zcubic le
nan170926T135353ZBrad Gil
005Husk170925T063339ZIcer Wil
015MATL170925T134604ZGiuseppe
039R170923T121820ZGiuseppe
074C# .NET Core170924T015451ZAyb4btu
076Java 8170925T075433ZKevin Cr
040Ruby170925T065452ZG B
00505AB1E170925T045859ZIcer Wil
012RProgN 2170925T041030ZATaco
028Stacked170924T211113ZConor O&
036Kotlin170924T142340Z2xsaiko
00605AB1E170924T084519ZEmigna
024J170923T220328ZJonah
020CJam170924T053001ZIaka Noe
nanPerl 5170924T035600ZXcali
043Jq 1.5170923T233012Zjq170727
009Japt170923T130440ZShaggy
034Mathematica170923T204821ZJungHwan
013Actually170923T201019Zuser4594
166BrainFlak170923T193422ZNitrodon
058Python 2170923T143233Ztotallyh
021QBIC170923T181948Zsteenber
045Haskell170923T162618Zjferard
055JavaScript ES6170923T150629ZShaggy
007Husk170923T121429ZH.PWiz
066Mathematica170923T125904ZZaMoC
042JavaScript ES6170923T121842ZArnauld
005SOGL V0.12170923T115818Zdzaima
007Husk170923T122454Zბიმო
047Python 3170923T121818ZLeaky Nu
050Python 2170923T120905Zorlp
007Jelly170923T121029ZLeaky Nu
053Python 2170923T120828Zanon

APL(NARS), 15 chars

{≢∊⍕¨∊⍴⍨¨¨⍳¨⍳⍵}

test:

   f←{≢∊⍕¨∊⍴⍨¨¨⍳¨⍳⍵}      
  f 1
1
  f 2
4
  f 3
10
  f 10
230
  f 50
42190
  f 100
339240
  f 150
1295790

Dyalog APL, 15 bytes

{≢∊⍕¨∊(/⍨⍳)¨⍳⍵}­⁡​‎‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁢‏‏​⁡⁠⁡‌­
            ⍳⍵   # ‎⁡Range of 1..input
      (   )¨     # ‎⁢For each of those numbers
         ⍳       # ‎⁣  range of 1..N again
       /⍨        # ‎⁤  and replicate with the same arg on left and right.
                 # ‎⁤  e.g. 1 2 3 / 1 2 3 -> 1 2 2 3 3 3
     ∊           # ‎⁢⁡Flatten
   ⍕¨            # ‎⁢⁢Convert each digit to a character
  ∊              # ‎⁢⁣Flatten again
 ≢               # Count
💎

Created with the help of Luminespire.

cQuents, 9 bytes

;b$
;$*S$

Try it online!

Explanation

;b$    first line
;      mode series - given input n, output the sum of the first n terms
       each term is
 b                  second line (               )
  $                               current index

;$*S$  second line
;      mode series - given input n, output the sum of the first n terms
       each term is
 $                  current index
  *                               times
   S                                    string (               )
    $                                            current index

Vyxal 3, 7 bytes

ɾD⇄×$Ŀ•

Vyxal It Online!

ɾD⇄×$Ŀ•­⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌­
ɾ        # ‎⁡range 1..input (inclusive)
 D       # ‎⁢triplicate
  ⇄      # ‎⁣reverse one copy
   ×     # ‎⁤multiply the reverse with the not-reversed
    $Ŀ   # ‎⁢⁡get the lengths of each number in the third copy
      •  # ‎⁢⁢multiply that and sum (dot product)
💎

Created with the help of Luminespire.

<script type="vyxal3">
ɾD⇄×$Ŀ•
</script>
<script>
    args=[["1"],["2"],["3"],["10"],["50"],["100"],["150"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

AWK, 36 bytes

{for(;i++<$1;)s+=t+=i*length(i)}$0=s

Attempt This Online!

Port of this clever answer.

I had made it this far (48 bytes):

{for(;i++<$1;)for(j=0;j++<i;)s+=length(j)*j}$0=s

J-uby, 32 bytes

:+|:*&(:+|:*&~:*%-[I])|:join|:+@

Attempt This Online!

Explanation

:+ | :* & (:+ | :* & ~:* % -[I]) | :join | :+@

:+ | :* & (                    )                # Range, then map with...
           :+ | :* &                            #   Range, then map with...
                     ~:* % -[I]                 #     [n] * n
                                 | :join | :+@  # Then join all elements and get length

Thunno 2 JL, 3 bytes

RJF

Try it online!

Or, 5 bytes flagless: RJFJl

Explanation

RJFJl  # Implicit input
R      # Range [1..input]
 J     # Join into a string
  F    # All substrings
   J   # Join into a string
    l  # Length of the string
       # Implicit output

Excel VBA, 66 51 50 Bytes

Anonymous VBE immediate window function that takes input from the range [A1] and outputs to the VBE

For i=1To[A1]:For j=1To i:s=s+j*Len(j):Next j,i:?s

Alternate Version, 94 Bytes

Anonymous VBE immediate window function that takes input,n, from range [A1] constructs the GUA(n) and outputs the length of it to the VBE immediate window

[B1].Resize([A1],1)="=IfError(Offset(B1,-1,0)&Rept(Row(),Row()),1)":?[Len(TextJoin("",1,B:B))]

Retina, 29 bytes

.+
$*
1
1$`¶
1
1$%`¶
1
$.%_
.

Try it online!

Explanation

.+
$*

Convert input to unary.

1
1$`¶

Turn the input N into a range from 1 to N by inserting the prefix up to each 1 after it, together with a linefeed.

1
1$%`¶

Do the same thing to each value in that range. This time we use $%`, which is just the prefix on the current line. So this gives 1, 1,2, 1,2,3, 1,2,3,4, ... (in unary). Now all we need to do is repeat each value accordingly and converting to decimal.

1
$.%_

This is done by replacing each 1 with the length of the line its on.

.

Finally we count the number of digits.

Ruby, 73 bytes

f=->(t){(1..t).map{|n|(1..n).map{|n|Array.new(n,n)}}.flatten.join.length}

Bash, 48, 44 bytes

Saved 4 bytes thanks to for + curly braces trick

for((;r+=t+=n*${#n},++n<=$1;));{ :;};echo $r

Röda, 31 bytes

{f={seq 1,_}f|f|[#`$_`*_1]|sum}

Try it online!

Powershell, 93 bytes

$a=@();$b=@();1..$n|% $_{$i=0;Do{$a+=$_;$i++}while($i-ne$_);$b+=$a-join''};($b-join'').Length

Code exploded a bit:

$inputNum = 10
$numbers = 1..$inputNum
$array = @()
$bigArray = @()
Foreach ($number in $numbers){
    $i = 0
    Do {
        $array += $number
        $i++
    }
    while ($i -ne $number)
    $bigArray += $array -join ''
}
($bigArray -join '').Length

[Dyalog APL], 22 20 bytes

{+/≢¨⍕¨↑,/(/⍨¨⍳¨⍳⍵)}

Try it online!

Explanation:

{+/≢¨⍕¨↑,/(/⍨¨⍳¨⍳⍵)}
{                  } anonymous function with right argument named ⍵
                ⍳⍵   range 1 to right arg
              ⍳¨     for each, range 1 to it
             ¨       for each
           /⍨          for each item, repeat right arg left arg times
          (       )  take that and
        ,/           join the sub-arrays together
       ↑             convert from a nested array to a simple array (or something like that, I don't quite understand it :p)
     ⍕¨              convert each number to a char-array (aka string version)
   ≢¨                get length of each
 +/                  sum that together

Ohm v2, 7 bytes

@@D×JJl

Try it online!

PocoLithp, 111 bytes

(define gau(#(N I)(if(!(defined I))(gau N 1)(if(!= N 0)(+(*(*(length(expl(str N)))N)I)(gau(- N 1)(+ I 1)))N))))

More readable version:

(define gau (# (N I) (begin
        (if (! (defined I))      ;; I not supplied, recurse with I set to 1
                (gau N 1)
                (begin           ;; I supplied, calculate
                        (define A (length (expl (str N))))  ;; `N`.length
                        (if (!= N 0)
                            ;; N != 0, head recursive calculation
                            (+ (* (* A N) I) (gau (- N 1) (+ I 1)))
                            ;; N == 0, return it
                             N)
                )
        )
)))

Usage:

(gau 123) => 662505
(gau 256) => 7532088

Named function gau, which takes 1 or 2 parameters. If called with 1 parameter, calls self with 2nd parameter set to 1. This implements the default variables used in other implementations.

This could possibly be made tail recursive, but it would likely be even longer than it already is.

Charcoal, 18 14 bytes

IΣE⊕NΣE⊕ι×λLIλ

Try it online! Link is to verbose version of code. Edit: Using Sum saved me 4 bytes. Explanation:

  E⊕N           Map from 0 to the input (loop variable i)
      E⊕ι       Map from 0 to i (loop variable l)
            Iλ  Cast l to string
           L    Take the length
         ×λ     Multiply by l
     Σ          Sum the results
 Σ              Sum the results
I               Cast to string
                Implicitly print

Jelly, 7 bytes

RRx`€VV

Try it online!

Explanation:

RRx`€VV    Example input: 3
R          Range. Result: [1, 2, 3]
 R         Range (vectorizes). Result: [[1], [1, 2], [1, 2, 3]]
    €      Apply to €ach...
  x`       Repeat each number itself times. Result: [[[1]], [[1], [2, 2]], [[1], [2, 2], [3, 3, 3]]]
     VV    Concatenate them into one big friendly number. Result: 1122122333

Scala, 44 bytes

(1 to n).map(i=>(i+"").length*i*(n+1-i)).sum

Try it online!

Perl 6, 36 bytes

{[+] 1..*Z*($_...1).map:{.chars*$_}}

Test it

Expanded:

{  # bare block lambda with implicit parameter 「$_」

  [+]               # reduce the following using &infix:«+»

    1 .. *          # Range from 1 to infinity

    Z*              # zip using &infix:«*»

    ( $_ ... 1 )    # sequence from the input down to 1
    .map:           # for each one
    { .chars * $_ } # multiply the number of digits with itself
}

Husk, 5 bytes

ṁLΣQḣ

Try it online!

Explanation

ṁ  map over
 L  length
  Σ  sum list
   Q  all sublists
    ḣ  range 1 .. N

MATL, 15 bytes

:ttP*Y"10&YlQks

Try it online!

Explanation:

:                range 1:input (implicit input)
 tt              duplicate twice
   P             reverse
    *            multiply elementwise
     Y"          runlength decoding
       10&Yl     log10
            Qk   increment and floor
              s  sum (implicit output)

R, 39 bytes

function(n)sum(nchar(rep(1:n,n:1*1:n)))

Verify all test cases!

Simple algorithm; I observed, as most did, that for i in 1:n, i is repeated i*(n-i+1) times. So I create that vector, count the number of characters in each, and sum them.

C# (.NET Core), 94 80 74 bytes

n=>{int b=0,a=0,i;while(a++<n)for(i=0;i++<a;)b+=(i+"").Length*i;return b;}

Try it online!

I was hoping to find a direct solution like what @kamoroso94's answer started, but gave up as I was spending too much time on it. There probably is a way of doing it, but the formula needs to adjust for every magnitude step.

Acknowledgements

14 bytes saved thanks to @someone

6 bytes saved thanks to @Kevin Cruijssen

Java 8, 76 bytes

n->{int r=0,i=0,j;for(;i++<n;)for(j=0;j++<i;r+=(j+"").length()*j);return r;}

I have the feeling this can be golfed with a more arithmetic approach, instead of using String#length..

Explanation:

Try it here.

n->{                        // Method with integer as both parameter and return-type
  int r=0,                  //  Result-integer
      i=0,j;                //  Index integers
  for(;i++<n;)              //  Loop (1) from 0 to the input (exclusive)
    for(j=0;                //   Reset `j` to 0
        j++<i;              //   Inner loop (2) from 0 to `i` (exlusive)
      r+=                   //    Append the result-String with:
         (j+"").length()*j  //     The length of `j` multiplied by `j`
    );                      //   End of inner loop (2)
                            //  End of inner loop (1) (implicit / single-line body)
  return r;                 //  Return result-String
}                           // End of method

Ruby, 41 40 bytes

->n{(1..n).map{|x|[x]*x*=-x-~n}*''=~/$/}

Try it online!

05AB1E, 5 bytes

LŒJJg

Try it online!

Explanation

L      # push [1 .. a]
 Œ     # all substrings (a)
  J    # numbers to strings (inner)
   J   # numbers to strings (outer)
    g  # length

RProgN 2, 12 bytes

{{]Ø.*}S.}S.

Try it online!

Stacked, 28 bytes

[~>[~>[:rep]"!]"!flat''#`#']

Try it online!

Some might ask, "At which point are aliases unreadable?" If this isn't close, you have a very liberal definition of "readability".

Explanation

[~>[~>[:rep]"!]"!flat''#`#']    input: N
 ~>[          ]"!               for each number K from 1 to N
    ~>[    ]"!                  for each number J from 1 to K
       :rep                     repeat J J times
                 flat           flatten the resultant array
                     ''#`       join by the empty string
                         #'     get the length of said string

Kotlin, 36 bytes

{x:Int->(1..x).flatMap{1..it}.sum()}

Test:

val GAU = {x:Int->(1..x).flatMap{1..it}.sum()}
GAU(5)
=> 35

05AB1E, 6 bytes

LLD×Jg

Try it online!

Explanation

L        # range [1 ... input]
 L       # for each range [1 ... x]
  D      # duplicate
   ×     # repeat each in the first list a number of times determined by the second list
    J    # join to string
     g   # length

J, 24 bytes

[:+/[:+/\[:(*#@":"0)1+i.

Similar high-level approach to dzaima's APL answer, translated into J, except we calculate the number's length by turning it into a string first instead of taking logs, and we get to use J's hook to multiply that length by the number itself: (*#@":"0). After that it's just the sum of the scan sum.

Try it online!

CJam, 20 bytes

q~),(\{),{_s,*+}*+}%

Try it online!

The number is passed in the "input" field.

Ungolfed explanation: (example input = 2)

q~),(\{),{_s,*+}*+}%                                             | Stack:
q                     read input as string                       | "2"
 ~                    eval input (add it to stack as integer)    | 2
  )                   add 1                                      | 3
   ,                  range (convert to array with values 0...N) | [0, 1, 2]
    (                 pop first item of array                    | [1, 2] 0
     \                swap top two values of stack               | 0 [1, 2]
      {           }   for each item in array...                  | 0 1
       )              add 1                                      | 0 2
        ,             range (convert to array with values 0...N) | 0 [0, 1]
         {     }      for every element in the array...          | 0 0
          _           duplicate                                  | 0 0 0
           s          convert to string                          | 0 0 "0"
            ,         get length of string                       | 0 0 1
             *        multiply                                   | 0 0
              +       add                                        | 0 1
                *     fold                                       | 0 1
                 +    add                                        | 1
                   %  repeat                                     | 4

It seems hard when explained lol.

Perl 5, 33 + 1 (-p) = 34 bytes

map{map$\+=$_*y///c,1..$_}1..$_}{

Try it online!

Jq 1.5, 82 49 43 bytes

[range(.)+1|range(.)+1|"\(.)"*.|length]|add

Expanded

[   range(.)+1        # for i=1 to N
  | range(.)+1        # for j=1 to i
  | "\(.)"*.          # "j" copied j times
  | length            # convert to length
] | add               # add lengths

Sample Run

$ jq -Mr '[range(.)+1|range(.)+1|"\(.)"*.|length]|add' <<< "150"
1295790

Try it online! also jqplay.org

Japt, 12 11 10 9 bytes

õõÈ*sÊÃxx

Try it or test all numbers from 1 to 150.


Explanation

Implicit input of integer U.

õõ

Generate an array of integers from 1 to U and then generate sub-arrays from 1 to each integer.

È   Ã

Pass the elements of each sub-array through a function.

*sÊ

Convert the current element to a string (s), get it's length (Ê) and multiply it by the element.

xx

Reduce the main array by addition after first doing the same to each sub-array.

Mathematica, 34 bytes

Sum[i⌊1+Log10@i⌋,{j,#},{i,j}]&

Actually, 13 bytes

R♂R♂i⌠;n⌡Mεjl

Try it online!

Explanation:

R♂R♂i⌠;n⌡Mεjl
R              range(1, n+1)
 ♂R            range(1, x+1) for x in previous
   ♂i          flatten into 1D list
     ⌠;n⌡M     for x in list:
      ;n       repeat x x times
          εj   concatenate to string
            l  length

Brain-Flak, 166 bytes

<>(((()()())({}){})())<>{({}[()]<({}({}<<>({}[()])((){[()](<()>)}{}){{}((((({})({})){}{}){}))<>(({}<({}())>){()<({}[({})])>}{})(<>)}{}<>>({}({})())))>)}{}({}<{}{}{}>)

Try it online!

Explanation

<>(((()()())({}){})())<>           # Initialize second stack with 9 and 10
{({}[()]<                          # Do main loop n times:
  ({}
    ({}
      <
        <>({}[()])                 # Subtract 1 from counter to next power of 10
        ((){[()](<()>)}{}){        # If reached a power of 10 (say, 10^k):
          {}((((({})({})){}{}){})) # Multiply existing (10^k*0.9) by 10 and push twice
          <>                       # On first stack
          (
            ({}<({}())>)           # Increment length of numbers
            {()<({}[({})])>}{}     # Divide length of new set of numbers by this length
          )                        # Add together to get new set of numbers length
        (<>)}  
      {}<>>  
      ({}({})())                   # Add number length to number set length
    )                              # Add number set length to new segment length
  )                                # Add new segment length to total length
>)}                                # End main loop
{}({}<{}{}{}>)                     # Put result on stack by itself

Python 2, 59 58 bytes

Another one bytes the dust thanks to Jonathan Frech.

f=lambda n:n and sum(i*len(`i`)for i in range(n+1))+f(n-1)

Try it online!

Not short but eh... what the heck.

QBIC, 21 bytes

[:|[a|[c|A=A+!c$}?_lA

Haskell, 45 bytes

f n=sum[j*length(show j)|i<-[1..n],j<-[1..i]]

Try it online!

JavaScript (ES6), 57 55 bytes

n=>[...Array(n)].reduce(x=>x+(++y+"").length*y*n--,y=0)

Try it online!

Husk, 7 bytes

ṁLṁṘNḣḣ

Try it online!

Explanation

          Implicit input, e.g 4
      ḣ   Range from 1 to n                               [1,2,3,4]
     ḣ    Prefixes                                        [[],[1],[1,2],[1,2,3],[1,2,3,4]]
  ṁ       Map and then concatenate
   ṘN     Repeat each number in each list by its index    [[],[1],[1,2,2],[1,2,2,3,3,3],[1,2,2,3,3,3,4,4,4,4]]
                                                          [1,1,2,2,1,2,2,3,3,3,1,2,2,3,3,3,4,4,4,4]
ṁ         Map and then sum
 L        Length (of number: 10 -> 2)                     26

Mathematica, 66 bytes

Tr[1^(f=Flatten)[IntegerDigits/@f@(a=Array)[a[#~Table~#&,#]&,#]]]&

JavaScript (ES6), 50 42 bytes

Updated: now basically a port of what other answers are doing.

f=(n,i=1)=>n&&`${n}`.length*n*i+f(n-1,i+1)

Test cases

f=(n,i=1)=>n&&`${n}`.length*n*i+f(n-1,i+1)

console.log(f(1))   // 1
console.log(f(2))   // 4
console.log(f(3))   // 10
console.log(f(10))  // 230
console.log(f(50))  // 42190
console.log(f(100)) // 339240
console.log(f(150)) // 1295790

SOGL V0.12, 11 10 8 7 5 bytes

∫∫l*+

Try it Here! - this expects to be called as a function with the input on the stack and the input box empty.
7 byte alternative taking the input from the input box:

0.∫∫l*+

Try it Here!

0      push 0
 .     push the input
  ∫    iterate over a range 1..POP (input) inclusive, pusing the current number
   ∫    iterate over 1..POP (above loops number) inclusive, pusing the current number
    l    push that numbers length without popping the number
     *   multiply the length by the number
      +  add to the zero, or whatever it is now

Husk, 7 bytes

Σ∫mS*Lḣ

Try it online!

Ungolfed/Explanation

         -- implicit input N                        | 10
  m   ḣ  -- map the following function over [1..N]  | [1,2,3,4]
   S*L   --   multiply length of number by itself   | [1,2,3,4] (only important for numbers ≥ 10)
 ∫       -- prefix sums                             | [0,1,3,6,10]
Σ        -- sum                                     | 20

Python 3, 47 bytes

f=lambda x,i=1:x and x*i*len(str(x))+f(x-1,i+1)

Try it online!

Python 2, 51 50 bytes

lambda n:sum(~k*(k-n)*len(`k+1`)for k in range(n))

Jelly, 7 bytes

Rx`ƤDFL

Try it online!

Python 2, 53 bytes

lambda x:sum(len(`i`)*i*(x-i+1)for i in range(1,x+1))

Try it online!