| Bytes | Lang | Time | Link |
|---|---|---|---|
| 050 | TXR Lisp | 170801T214021Z | Kaz |
| 007 | Pip | 240821T193258Z | DLosc |
| 014 | J | 240821T113813Z | Galen Iv |
| 050 | Red | 240821T112550Z | Galen Iv |
| 032 | Arturo | 230204T192930Z | chunes |
| 040 | Excel VBA | 240129T212928Z | Taylor R |
| 003 | Thunno 2 S | 230608T165135Z | The Thon |
| 012 | GolfScript | 230228T160554Z | emirps |
| nan | 230204T121653Z | The Thon | |
| 102 | Magneson | 170801T094244Z | Brella |
| 004 | Japt x | 221214T124918Z | Shaggy |
| 068 | ><> | 221214T123203Z | Emigna |
| 016 | Juby | 221121T003825Z | Jordan |
| 013 | K ngn/k | 220505T134932Z | oeuf |
| 038 | Julia 1.0 | 220509T100137Z | MarcMush |
| 052 | Python 3 | 220509T074058Z | Number B |
| 070 | Desmos | 220503T193720Z | naffetS |
| 007 | Burlesque | 220503T202958Z | DeathInc |
| 039 | Factor + math.unicode | 220503T195228Z | chunes |
| 028 | Vim | 210411T054706Z | Leo |
| 059 | Excel | 210411T131806Z | Axuary |
| 004 | Arn x | 210411T024237Z | ZippyMag |
| 046 | vim | 210410T224347Z | Ray |
| 081 | Java OpenJDK 8 | 210410T222213Z | Donat |
| 127 | Python 3 | 210410T204025Z | Symmetr1 |
| 075 | R | 170801T151723Z | Giuseppe |
| 027 | x86 | 210410T143502Z | l4m2 |
| 043 | PowerShell | 210410T115903Z | mazzy |
| 089 | PowerShell | 210410T040151Z | wasif |
| 002 | Vyxal | 210228T065318Z | Razetime |
| 059 | Lua | 210301T004549Z | J. А. de |
| 007 | Canvas | 210228T071847Z | hakr14 |
| 026 | Gol><> | 180222T082348Z | Unihedro |
| 003 | Pyt | 180222T000121Z | qqq |
| 018 | J | 171230T065826Z | Bolce Bu |
| nan | Perl 5 | 170801T014530Z | Xcali |
| 007 | Pyth | 171230T054825Z | Tornado5 |
| 010 | Recursiva | 171229T092158Z | 0xffcour |
| 3835 | Ruby | 171214T174453Z | Unihedro |
| 007 | Gaia | 171214T191441Z | Giuseppe |
| 039 | Ruby | 170801T163723Z | akostadi |
| 003 | Husk | 170801T013515Z | ბიმო |
| 084 | Java 8 | 170905T152605Z | Jakob |
| 146 | C++ | 170801T012446Z | HatsuPoi |
| 049 | Excel VBA | 170801T154558Z | Taylor R |
| 011 | MY | 170731T235953Z | Adalynn |
| 005 | Japt | 170731T234233Z | Justin M |
| 068 | Swift 3 | 170802T182918Z | idrougge |
| 013 | k | 170812T193208Z | zgrep |
| 061 | Swift 4 | 170801T065636Z | Mr. Xcod |
| nan | 170731T232810Z | Brad Gil | |
| 072 | Javascript | 170801T011523Z | SuperSto |
| 097 | Java 8 | 170803T103309Z | Akash Th |
| 046 | REXX | 170802T172819Z | idrougge |
| 036 | Röda | 170801T165300Z | user4180 |
| 062 | Common Lisp | 170802T094217Z | Renzo |
| 007 | APL Dyalog | 170801T131906Z | user4180 |
| 110 | Rust | 170802T092031Z | jferard |
| 050 | Python 3 | 170802T090359Z | Łukasz R |
| 024 | Bash + GNU utils | 170731T232654Z | Digital |
| 012 | CJam | 170801T150502Z | Erik the |
| 035 | Retina | 170731T234905Z | Neil |
| 391 | PHP | 170801T165138Z | Titus |
| 071 | C gcc | 170801T155813Z | Giacomo |
| 015 | GolfScript | 170801T150808Z | Erik the |
| 047 | Python 2 | 170731T232839Z | notjagan |
| 053 | PowerShell | 170801T131114Z | AdmBorkB |
| 097 | C# .NET Core | 170801T020619Z | Kamil Dr |
| 098 | Swift 3 | 170801T121936Z | Sergii M |
| 033 | LOGO | 170801T093450Z | user2027 |
| 004 | Neim | 170801T092112Z | space ju |
| 066 | Tcl | 170801T081320Z | sergiol |
| 005 | MATL | 170801T081052Z | Cinaski |
| 007 | Pyke | 170801T074351Z | Blue |
| 013 | Charcoal | 170801T002725Z | ASCII-on |
| 004 | Brachylog | 170801T065752Z | DanTheMa |
| 019 | QBIC | 170801T060648Z | steenber |
| 063 | C gcc | 170801T053228Z | Leaky Nu |
| 043 | Pari/GP | 170801T025015Z | alephalp |
| 034 | Haskell | 170801T011441Z | Silvio M |
| 031 | Ly | 170801T011420Z | LyricLy |
| 042 | JavaScript ES6 | 170801T010459Z | ETHprodu |
| 004 | Jelly | 170801T004907Z | Jonathan |
| 006 | Pyth | 170731T234402Z | notjagan |
| 005 | Jelly | 170731T233905Z | nmjcman1 |
| 008 | RProgN 2 | 170731T234121Z | ATaco |
| 003 | 05AB1E | 170731T233702Z | Adnan |
| 038 | Python 2 | 170731T233549Z | Adnan |
| 004 | cQuents | 170731T233343Z | Stephen |
| 047 | Mathematica | 170731T232404Z | ZaMoC |
TXR Lisp: 62 56 52 50 bytes:
(lopip(range 1)(sum(opip tostring reverse toint)))
Interactive:
1> (lopip(range 1)(sum(opip tostring reverse toint)))
#<intrinsic fun: 0 param + variadic>
2> [*1 10]
46
3> [*1 999]
454545
Pip, 7 bytes
$+R*\,a
Explanation
a ; Command-line argument
\, ; 1-based inclusive range
R* ; Reverse each
$+ ; Fold on addition
Arturo, 52 32 bytes
$=>[∑map&'x->do reverse~"|x|"]
Yikes, this was bad. I immediately found 20 bytes of savings looking back on this a year and a half later.
Excel VBA, 40 bytes
Anonymous Immediate window function that takes input from cell [A1] of the activesheet object and outputs to the Immediate Window console.
For i=1To[A1]:u=u--StrReverse(i):Next:?u
Thunno 2 S, 3 bytes
RṃN
Explanation
RṃN # Implicit input -> 10
R # Push [1..input] -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ṃ # Reverse each -> [1, 2, 3, 4, 5, 6, 7, 8, 9, '01']
N # Cast each to int -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]
# S flag sums the list -> 46
# Implicit output
GolfScript, 12 bytes
,{)`-1%~+}*)
Explanation
code # explanation | stack
,{)`-1%~+}*) # function with input n | n
, # range | [0..n)
{ }* # fold this block over | [0..n)
) # increment | [1..n]
` # stringify | ["1"..str(n)]
-1% # map by -1 (reverse) | [rev("1")..rev(str(n)]
~ # eval | [rev(1)..rev(n)]
+ # add (effectively sum) | sum([rev(1)..rev(n)])
) # increment | sum([rev(1)..rev(n)])+1
Thunno +, \$4\log_{256}(96)\approx\$ 3.29 bytes
R.rS
Explanation
R.rS # Implicit input
# + flag adds one
R # Range
.r # Reverse each
S # Sum
# Implicit output
Magneson, 102 bytes
That's not very visible, so here's a scaled up version (Note: Won't actually run, and still isn't very pretty)

(source: googleapis.com)
Magneson operates by parsing an image and evaluating commands from the colours of the pixels it reads. So stepping through the image for this challenge, we have:
R: 0, G: 1, B: 1is an integer assignment command, which takes a string for the variable name and the value to assign. We'll use this to store the sum total.R: 0, G: 1, B: 0is a prebuilt string with the valueVAR_1(Note: This is only while we're asking for a string; the colour code has a separate function when used elsewhere).R: 3, G: 0, B: 0is a raw number. Magneson handles standard numbers by requiring the Red component to be exactly 3, and then forms a number by using the blue value directly plus the green value multiplied by 256. In this case, we're just getting the number 0.R: 0, G: 1, B: 1is another integer assignment command. This time, we're storing an iteration variable, to keep track of which number we're onR: 0, G: 1, B: 1is a prebuilt string with the valueVAR_2(Once more, only when we need a string)R: 3, G: 0, B: 0is the number 0, once more. Onto the interesting bits now.R: 1, G: 0, B: 0indicates the start of a loop. This takes a number and loops the following snippet of code that many times.R: 2, G: 0, B: 0is the STDIN function, or at least it is when we need a number. This reads a line of input from the console and turns it into a number, since we asked for a number.R: 0, G: 8, B: 0starts off our looping code, and it is an additive command. This adds a number to an integer variable, and so takes a string for the variable name, and the number to add.R: 0, G: 1, B: 1is the prebuilt string forVAR_2, which is our iteration variable.R: 3, G: 0, B: 1is a raw number, but this time it's the number 1.R: 0, G: 8, B: 0is another addition command.R: 0, G: 1, B: 0is the string forVAR_1, which is our sum total.R: 0, G: 3, B: 0is a function that reverses a string. In the context of asking for a number, it then converts the reversed string to a number.R: 0, G: 2, B: 1is an integer retrieval command, and will retrieve the number stored in a provided variable. In the context of asking for a string (such as from the reverse command), it converts the number to a string.R: 0, G: 1, B: 1is the nameVAR_2; our iteration variable.R: 1, G: 0, B: 1is the marker to end the loop, and go back to the start of the loop if the criteria isn't met (so if we need to keep looping). Otherwise, proceed onwards.R: 0, G: 0, B: 1is a very simple println command, and takes a string.R: 0, G: 2, B: 1retrieves an integer from a variableR: 0, G: 1, B: 0is the name of our sum total variable,VAR_1
All in all, the program:
- Assigns the value 0 to
VAR_1andVAR_2 - Loops from 0 to a number provided in STDIN
- Adds one to
VAR_2 - Adds the integer value of reversing
VAR_2toVAR_1
- Adds one to
- Prints the contents of
VAR_1
Japt -x, 4 bytes
õÈìÔ
õÈìÔ :Implicit input of integer
õ :Range [1,input]
È :Map
ì : Convert to digit array
Ô : Reverse and implicitly convert back
:Implicit output of sum of resulting array
J-uby, 16 bytes
:+|:sum+(S|:~|Z)
Explanation
Same idea as the Ruby answers but J-uby helps us out with some handy shortcuts.
:+ | :sum + (S | :~ | Z)
:+ | # Make range 1..n, then
:sum + ( ) # Sum of items...
S | # Converted to string, then
:~ | # Reversed, then
Z # Converted to int
Julia 1.0, 38 bytes
!x=sum(Meta.parse∘join∘digits,1:x)
this works because digits returns an array with the digits starting with the least significants first (digits(123) == [3, 2, 1])
alternative, also 38 bytes (but more chars and not as nice)
!x=sum(@.parse(Int,join(digits(1:x))))
Python 3, 52 bytes
lambda n:sum(int(str(n+1)[::-1])for n in range(n))
lambda n:sum(int(f'{n+1}'[::-1])for n in range(n))
The second is equivalent to the first.
Desmos, 72 70 bytes
l=floor(logx)
f(y)=∑_{x=1}^y∑_{n=0}^lmod(floor(x/10^n),10)10^{l-n}
-2 bytes thanks to Aiden Chow
Factor + math.unicode, 39 bytes
[ [1..b] [ >dec reverse dec> ] map Σ ]
Using build 2166 for the somewhat recent addition of >dec.
Vim, 39 37 28 bytes
D@"O<C-V><C-A>0<ESC>V{g<C-A>:%!rev
v}gJS0<ESC>@"
Tons of bytes saved thanks to some great advice by user41805
Explanation
Step 1: build the range (with summing commands included)D@"O<C-V><C-A>0<ESC>V{g<C-A>
D Delete the input number
@" <ESC> Do that many times:
O Insert a new line above
<C-V><C-A> Write a <C-A> byte (\x01)
0 Followed by a 0
V{ Select all the lines just written
g<C-A> Turn the numbers into an increasing range
Step 2: reverse each number
:%!rev (that's it)
This will produce a sequence of lines with the reversed number followed by <C-A>, which is the command to increase a value by the reversed number. Leading 0s actually move the pointer to the beginning of the line, so they are effectively ignored.
v}gJS0<ESC>@"
v} Select all the lines to the end of the file
gJ Join them
S Replace this line
0<ESC> with a 0
@" Execute the replaced line as commands
Excel, 59 bytes
=LET(y,COLUMN(A:O),SUM((0&MID(SEQUENCE(A1),y,1))*10^(y-1)))
Explanation
=LET(
y,COLUMN(A:O) 'y = [1..15] horz.; Excel is accurate to 15 places
SUM((0&MID(SEQUENCE(A1),y,1))*10^(y-1)) 'final result
SEQUENCE(A1) '[1..A1] vertical
(0&MID( ,y,1)) 'array of individual digits; 0& is to avoid errors on blank cells
*10^(y-1) 'multiply 2nd column by 10, 3rd 100, etc.
SUM( ) 'sum the array
Arn -x, 4 bytes
P▀g³
Explained
Unpacked: ~)@.<
~ One-range to
_ Input; implied
)
@ Map with
.< Reverse fix
Implicit sum
vim, 49 46 bytes
A@q<ESC>0"bDa1<ESC>qqYp<C-a>q@bdk:%s/$/+
:%!rev
xVGJ:%!bc
<ESC> is 0x1b,
<C-a> is 0x01,
<NL> is 0x0a.
Annotated
A@q<ESC>0"bD # put {N}@q (run macro q N times) in register b
a1<ESC> # buffer now contains "1"
qqYp<C-a>q # store macro that copies and increments the last line in register q
@bd1k # run {N} times, then delete the extra lines
# (can't just run {N-1} times, or it won't handle N=1 correctly)
:%s/$/+<NL> # append + to each line
:%!rev<NL> # reverse each line
x # delete leading +
VGJ # join lines
:%!bc<NL> # sum
Java (OpenJDK 8), 81 bytes
long g(int n){return n<1?0:new Long(""+new StringBuffer(""+n).reverse())+g(n-1);}
Python 3, 127 bytes
def f(n):
s=0
for i in range(1,n+1):
r=""
k=str(i)
for j in range(0,len(k)):
r=r+k[len(k)-1-j]
s+=int(r)
return s
R, 89 75 bytes
sum(scan(t=sapply(1:scan(),function(x)intToUtf8(rev(utf8ToInt(c(x,'')))))))
Thanks to JayCe and Dominic van Essen for the golfs.
x86, 27 bytes
f: xor esi, esi ; Input ecx
push 10
pop ebx
.p: mov eax, ecx
xor edi, edi
.q: xor edx, edx
div ebx
imul edi, 10
add edi, edx
test eax, eax
jnz .q
add esi, edi
loop .p
ret ; Output esi
Seem not answered
PowerShell, 43 bytes
1.."$args"-join'+'|% t*y|%{$s=$_+$s}
$s|iex
This script converts a range [1,2,3,4,5,6,7,8,9,10] to the reversed string 01+9+8+7+6+5+4+3+2+1 and evaluates the string
PowerShell, 89 bytes
param($n)function q($x){(($a=$x|% t*y)|%{$a[--$i]})-join''}1..$n|%{$s+=[int](q("$_"))};$s
Lua (59 bytes)
function r(u)return u<1 and 0 or(u..""):reverse()+r(u-1)end
Gol><>, 26 bytes
&IFLPWaSD$|~rlMFa*+|&+&|&h
Explanation
&I &h < register init, read "n"; print register (h = n;)
FLP | < For loop, do "n" times for each x in [1] to [n]
WaSD$| < modpow "x" to digits: [123] [3 12] [3 2 1] [3 2 1 0]
~rlMFa*+| < Ditch zero, reverse stack, build the number back
&+& < register += final x
J, 18 Bytes
+/(".@|.@":)"0>:i.
Explanation:
+/ | Sum of
(".@|.@":) | Reverse
"0 | Each member of
>:i. | Integers from 1 to n inclusive
Pyth - 7 bytes
sms_`dS
Explanation
sms_`dSQ Q added implicitly
s Sum of
m map
s_`d integer representation of reversal of string representation
to
SQ Range from 1 to input
Ruby, 38 35 bytes
Similar to the previous Ruby solution, but a full program and also shorter (for less than an hour)!
p (?1..gets).sum{|x|x.reverse.to_i}
Shortened by 3 bytes thanks to user akostadinov
Explanation
p # Inspect and print. Written as infix notation to avoid using ()
(?1..gets) # All strings from "1" to "input", based on successive string format
.sum{|x| # Enumerable -> Map to value -> Sum by value
x.reverse.to_i
}
Gaia, 7 bytes
@…)¦v¦Σ
Range, Reverse, and sum!
@ # push an input. stack: n
… # generate range. stack: [0...n-1]
)¦ # map over the list with increment. stack: [1...n]
v¦ # map over the list with reverse. stack: [1...n], but all digitally reversed
Σ # sum the list; output TOS.
Ruby, 56, 52, 41, 39 bytes
->n{(1..n).sum{|i|i.to_s.reverse.to_i}}
Ruby, 34 bytes (if lambda param is a string)
->n{(1..n).sum{|i|i.reverse.to_i}}
Thanks to @Unihedron for the second solution.
Husk, 7 6 3 bytes
ṁ↔ḣ
Ungolfed/Explanation
ḣ -- With the list [1..N] ..
ṁ -- .. do the following with each element and sum the values:
↔ -- reverse it
Java 8, 84 bytes
Lambda from int to long (e.g. IntToLongFunction). Adaptation of coder-croc's solution.
n->{long s=0;while(n>0)s+=new Long(new StringBuffer(""+n--).reverse()+"");return s;}
C++, 146 bytes
#include<string>
using namespace std;int r(int i){int v=0,j=0;for(;j<=i;++j){auto t=to_string(j);reverse(t.begin(),t.end());v+=stoi(t);}return v;}
Excel VBA, 80 78 49 Bytes
Anonymous VBE Immediate Window function that takes input expected type Integer from range [A1] determines all of the values that fall within the range 1:[A1], and outputs the sum of the reversed values to the VBE immediate window
For i=1To[A1]:s=s+Val(StrReverse(Str(i))):Next:?s
MY, 11 bytes
𝕫iC4ǵ'ƒ⇹(Σ↵
How?
𝕫input as integeri[1 ... pop()] inclusiveC4ǵ'push the string'\x4C'(The reverse command (⌽), which works on numbers)ƒas a function⇹mapped over the argument (pushes a function)(apply the functionΣsum↵output with a new line
MY is capable of something, woohoo!
Japt, 7 5 bytes
-2 bytes thanks to @Shaggy.
õs xw
Explanation
õs xw Implicit input of integer U
õs Create range [1,U] and map to strings
w Reverse each string
x Sum the array, implicitly converting to numbers.
Old solution, 7 bytes
Keeping this since it's a really cool use of z2.
õs z2 x
Explanation
õs z2 x Implicit input of integer U
õs Create range [1,U] and map to strings
z2 Rotate the array 180°, reversing strings
x Sum the array, implicitly converting back to integers
Swift 3, 83 68 characters
let f={n in Array(1...n).reduce(0){$0+Int(String("($1)".characters.reversed()))!}}
{(1...$0).reduce(0){$0+Int(String("\($1)".characters.reversed()))!}}
This would probably be shortened by Swift 4's new String and Character handling.
k, 13 bytes
+/.:'|:'$1+!:
1+!: /create list 1 2 3 ... x
$ /turn each number into a string
|:' /reverse each string
.:' /eval each string
+/ /sum
Swift 4, 63 61 bytes
{v in(1...v).reduce(0,{$0+Int(String("\($1)".reversed()))!})}
Explanation
{v in}- Creates an anonymous (lambda-like) function with a parameterv.(1...v)- Inclusive range from1tov(although it kind of breaks the rules of logic).Int(String("\($1)".reversed()))- Reverses the Number by converting it to a String, returningReverseCollection<String>. That cannot be casted directly to an integer (Swift borked types!), so we have to cast it to String again, before making the conversion to an Integer.reduce(0,{$0+...})- Sums the mapped range.
Perl 6, 20 bytes
{(1..$_)».flip.sum}
Expanded:
{
( 1 .. $_ )\ # Range
».flip # flip each value in the Range (possibly in parallel)
.sum # sum up the list
}
Javascript,89 77 72 bytes
saved 12 bytes thanks to @Justin Mariner
saved 5 bytes thanks to @Neil
n=>-eval(`-'${[...[...Array(n+1).keys()].join`'-'`].reverse().join``}'`)
Explanation:
[...Array(n+1).keys()] creates an array from 0 to n.
.reverse().join`` reverses every value.
.join`'-'` and eval(`-'{stuff}'`) subtracts the values in order, producing the negative of the answer.
- negates the negative to a positive.
Java 8, 97 bytes
IntStream.range(1,n+1).map(i->Integer.valueOf(new StringBuffer(""+i).reverse().toString())).sum()
EDIT
As per the comment of Kevin Cruijssen, I would like to improve my answer.
Java 8, 103 bytes
n->java.util.stream.LongStream.range(1,n+1).map(i->new Long(new StringBuffer(""+i).reverse()+"")).sum()
REXX, 46 bytes
arg n
s=0
do i=1 to n
s=s+reverse(i)
end
say s
Röda, 56 41 36 bytes
15 bytes saved thanks to @fergusq
{seq 1,_|parseInteger`$_`[::-1]|sum}
This is an anonymous function that takes an integer from the input stream and outputs an integer to the output stream.
Explanation
{seq 1,_|parseInteger`$_`[::-1]|sum} Anonymous function
seq 1,_ Create a sequence 1 2 3 .. input and push each value to the stream
| For each value in the stream:
`$_` Cast it into a string
[::-1] And reverse it
parseInteger And parse the resulting string as an integer, while pushing the value to the stream
|sum Sum all the values in the stream
APL (Dyalog), 10 7 bytes
3 bytes golfed thanks to @Adám by converting to a tradfn from a train
+/⍎⌽⍕⍳⎕
⎕ Input (example input: 10)
⍳ Range; 1 2 3 4 5 6 7 8 9 10
⍕ Stringify; '1 2 3 4 5 6 7 8 9 10'
⌽ Reverse; '01 9 8 7 6 5 4 3 2 1'
⍎ Evaluate; 1 9 8 7 6 5 4 3 2 1
+/ Sum; 46
Rust, 110 bytes
|x:i64|(1..x+1).map(|v|format!("{}",v).chars().rev().collect::<String>().parse::<i64>().unwrap()).sum::<i64>()
I like Rust, but it is not a very efficient language for golfing!
Python 3, 50 bytes
lambda n:sum(int(str(n)[::-1])for n in range(n))
Quite close to idiomatic Python code, and honestly I don't really see much room for improvement.
Bash + GNU utils, 24
seq $1|rev|paste -sd+|bc
Explanation
seq $1 # range
|rev # reverse (each line)
|paste -sd+|bc # sum
CJam, 12 bytes
ri){sW%i}%:+
-1 thanks to Business Cat.
Explanation:
ri){sW%i}%:+
r Get token
i To integer
) Increment
{sW%i} Push {sW%i}
s To string
W Push -1
% Step
i To integer
% Map
:+ Map/reduce by Add
Retina, 41 36 35 bytes
.+
$*
1
1$`¶
1+
$.&
%O^$`.
.+
$*
1
Try it online! Link includes test cases. Edit: Saved 5 bytes thanks to @FryAmTheEggman. Saved 1 byte thanks to @PunPun1000. Explanation:
.+
$*
Convert to unary.
1
1$`¶
Create a range from 1 to n.
1+
$.&
Convert back to decimal.
%O^$`.
Reverse each number.
.+
$*
Convert back to unary.
1
Sum and convert back to decimal.
PHP, 39+1 bytes
while($i++<$argn)$s+=strrev($i);echo$s;
Run as pipe with -nR.
C (gcc), 71 bytes
q(n,x,p){p=n?q(n/10,x*10+n%10):x;}f(w,a,e){for(a=0;w;)a+=q(w--,0);e=a;}
GolfScript, 15 bytes
~),{`-1%~}%{+}*
Explanation:
~),{`-1%~}%{+}* Input all at once
~ Eval
) Increment
, Exclusive range
{ } Push block
` Repr
-1 -1
% Every xth element
~ Eval
% Map
{ } Push block
+ Add
* Reduce
Python 2, 50 47 bytes
-3 bytes thanks to officialaimm!
lambda n:sum(int(`i+1`[::-1])for i in range(n))
PowerShell, 53 bytes
(1.."$args"|%{-join"$_"["$_".length..0]})-join'+'|iex
Literal translation of the specification. Creates a range with .., reverses each by using string manipulation and -joining them back into a single number, then -joins each number together with a + and piping that to iex (short for Invoke-Expression and similar to eval).
C# (.NET Core), 103 97 bytes
using System.Linq;r=>new int[r+1].Select((_,n)=>int.Parse(string.Concat((n+"").Reverse()))).Sum()
TIO link outputs all the results from 1 to 999, so feel free to check my work.
I expected this to be a bit shorter, but it turns out Reverse() returns an IEnumerable<char> instead of another string so I had to add some extra to turn it back into a string so I could parse it to an int. Maybe there's a shorter way to go from IEnumerable<char> to int correctly.
Of minor note, this also uses the functions Range() Reverse() and Sum() all in order.
-6 bytes thanks to TheLethalCoder
Swift 3, 98 bytes
func f(a:Int)->Int{return (0...a).map{Int(String(String($0).characters.reversed()))!}.reduce(0,+)}
LOGO, 33 bytes
[reduce "+ map "reverse iseq 1 ?]
There is no "Try it online!" link because all online LOGO interpreter does not support template-list.
That is a template-list (equivalent of lambda function in other languages).
Usage:
pr invoke [reduce[?+reverse ?2]iseq 1 ?] 10
(invoke calls the function, pr prints the result)
prints 46.
Explanation:
LOGO stores numbers as words, therefore apply reverse on a number reverse the digits in that number.
reduce "f [a b c d e] (where [a b c d e] is a list) will calculate f(a, f(b, f(c, f(d, e)))). So reduce "+ list will calculate sum of values of list.
Pyke, 7 bytes
SF`_b)s
S - range(1, input)
F ) - for i in ^:
` - str(i)
_ - reversed(^)
b - int(^)
s - sum(^)
Charcoal, 14 13 bytes
-1 byte thanks to Carlos Alejo
I∕…·⁰N«⁺ιI⮌Iκ
Try it online! Link is to verbose version.
Explanation
I Cast
∕ « Reduce
…·⁰N Inclusive range from 0 to input as number
⁺ Plus
ι i
I⮌Iκ Cast(Reverse(Cast(k)))
QBIC, 19 bytes
[:|_F!a$|p=p+!A!}?p
Explanation
[:| FOR a = 1 to n (read from cmd line)
_F | FLIP and assign to A$
!a$ a string cast of our loop counter
p=p+!A! increment p with A$ cast back to number
} NEXT
?p Print the result
Haskell, 34 bytes
\n->sum$read.reverse.show<$>[1..n]
Simple and straightforward.
JavaScript (ES6), 42 bytes
f=n=>n&&+[...n+""].reverse().join``+f(n-1)
My favorite doubly-recursive solution is unfortunately 3 bytes longer:
f=n=>n&&+(g=x=>x?x%10+g(x/10|0):"")(n)+f(n-1)
Jelly, 4 bytes
Ṛ€ḌS
How?
Ṛ€ḌS - Link: n
Ṛ€ - reverse for €ach (in implicit range)
Ḍ - convert from decimal list (vectorises)
S - sum
Jelly, 5 bytes
RDUḌS
R ' [R]ange
D ' Integer -> [D]ecimal
U ' [U]pend (vectorized reverse?)
Ḍ ' [Ḍ]ecimal -> Integer
S ' [S]um
RProgN 2, 8 bytes
{Ø.in}S+
Explained
{Ø.in}S+
{ }S # Create a stack in range 0 through the implicit input, using the function defined
Ø. # Append nothing, stringifying the number
i # Reverse the string
n # Convert back to a number
+# Get the sum of the stack, and output implicitly.
05AB1E, 3 bytes
Code
LíO
Uses the 05AB1E encoding. Try it online!
Explanation
L # Range
í # Reverse
O # Sum
Python 2, 38 bytes
Can't compute higher terms than the recursion limit:
f=lambda x:x and int(`x`[::-1])+f(x-1)
cQuents, 4 bytes
;\r$
Explanation
Implicit input n.
; Series mode. Outputs the sum of the sequence from 1 to n.
\r$ Each item in the sequence equals:
\r String reverse of
$ current index (1-based)
Mathematica, 47 bytes
Tr[FromDigits@*Reverse/@IntegerDigits@Range@#]&
Try it online! (in order to work on mathics we need to replace "Tr" with "Total")

