| Bytes | Lang | Time | Link |
|---|---|---|---|
| 044 | AArch64 machine code | 250607T063031Z | 鳴神裁四点一号 |
| 015 | Excel | 240712T000858Z | z.. |
| 014 | AWK | 241029T201453Z | xrs |
| 004 | TIBasic | 241103T152545Z | Youserna |
| 034 | Clojure | 240906T104408Z | NikoNyrh |
| 018 | Perl 5 pa | 240905T180934Z | Xcali |
| 010 | ARBLE | 240905T061833Z | ATaco |
| 044 | F# .NET Core | 240905T060546Z | dtanku |
| 040 | gnuplot 5.0 | 240815T193205Z | Glory2Uk |
| 013 | Excel | 240814T015320Z | Taylor R |
| 009 | Juby | 240712T193339Z | noodle p |
| 034 | excel | 240716T092135Z | pneumann |
| 100 | Forth gforth | 240715T093323Z | david |
| 013 | Octave | 240714T133034Z | Tom Carp |
| 002 | Japt mx | 240712T205301Z | Shaggy |
| 028 | JavaScript V8 | 240713T224123Z | Andrew B |
| 030 | Retina | 240713T185622Z | Neil |
| 014 | Desmos | 240713T160252Z | Aiden Ch |
| 005 | J | 240712T014603Z | noodle p |
| 032 | Java | 240712T023659Z | Unmitiga |
| 012 | Julia 1.0 | 240712T205413Z | Ashlin H |
| 023 | min | 240712T200619Z | chunes |
| 002 | Pyt | 240712T131558Z | Kip the |
| 007 | Brachylog | 240712T115821Z | Fatalize |
| 853 | C gcc | 240712T114054Z | kevidryo |
| 033 | PowerShell Core | 240712T100433Z | Julian |
| 003 | Pyth | 240712T091144Z | Mukundan |
| 027 | Google Sheets | 240711T233415Z | doubleun |
| 029 | Bash | 240712T082329Z | Themooni |
| 115 | Whitespace | 240712T080008Z | Kevin Cr |
| 005 | Charcoal | 240712T001352Z | Neil |
| 012 | R | 240712T070250Z | Glory2Uk |
| 001 | Vyxal s | 240712T065713Z | Kevin Cr |
| 002 | 05AB1E | 240712T065301Z | Kevin Cr |
| 024 | Cognate | 240712T050821Z | chunes |
| 008 | Wolfram Language Mathematica | 240712T045510Z | Greg Mar |
| 004 | APLDyalog Unicode | 240712T032151Z | Mukundan |
| 004 | Uiua | 240711T220003Z | noodle p |
| 014 | Factor | 240712T015607Z | chunes |
| 041 | Red | 240712T014531Z | chunes |
| 026 | JavaScript Node.js | 240712T002141Z | l4m2 |
| 019 | Arturo | 240711T231748Z | chunes |
| 137 | sed 4.2.2 rz | 240711T223447Z | guest430 |
| 026 | Python 3.8 prerelease | 240711T202931Z | squarero |
| 017 | Haskell | 240711T203506Z | xnor |
| 042 | Nibbles | 240711T202550Z | Dominic |
| 007 | APL+WIN | 240711T200539Z | Graham |
| 003 | Jelly | 240711T193202Z | Fmbalbue |
AArch64 machine code, 44 bytes
For simplicity I am supporting 8-bit unsigned integers only for input. Can output 64-bit value. No overflow checks.
0000000000000000 <f>:
0: aa1f03e0 mov x0, xzr
4: 38401509 ldrb w9, [x8], #1
8: b5000049 cbnz x9, 10 <f+0x10>
c: d65f03c0 ret
10: d280002a mov x10, #0x1 // #1
14: aa0903eb mov x11, x9
18: 9b0b7d4a mul x10, x10, x11
1c: d1000529 sub x9, x9, #0x1
20: b5ffffc9 cbnz x9, 18 <f+0x18>
24: 8b0a0000 add x0, x0, x10
28: 17fffff7 b 4 <f+0x4>
Original source
/// fn (x8: [*:0]const u8) x0: u64
.globl f
f:
mov x0,xzr
1:
ldrb w9,[x8],1
cbnz x9,3f
ret
3:
mov x10,1 // power to be added
mov x11,x9
2:
mul x10,x10,x11
sub x9,x9,1
cbnz x9,2b
add x0,x0,x10
b 1b
How I tested on Termux
$ cat main.s
//! Usage: $0 BINARY
//! Outputs binary
.globl _start
_start:
ldr x8,[sp,16]
bl f
str x0,[sp,-8]!
mov x0,1
mov x1,sp
mov x2,8
mov x8,64
svc 0
mov x0,0
mov x8,93
svc 0
$ as -o f.o f.s && as -o main.o main.s && ld -o main f.o main.o
$ ./main $'' | od -An -tu8
0
$ ./main $'\4\6\7' | od -An -tu8
870455
$ ./main $'\xff' | od -An -tu8
6455757693289234175
$ bc <<< '(255^255)%(2^64)'
6455757693289234175
Excel, 15 bytes
Expects input in A1:A
=SUM(A:.A^A:.A)
AWK, -vRS="," 27 14 bytes
{x+=$0^$0}$0=x
This will print the running total for each number. TIO doesn't do it quite right, however.
{for(;i++<NF;)x+=$i^$i}$0=x
TI-Basic, 4 bytes
sum(Ans^Ans
Takes input in Ans.
Clojure, 34 bytes
#(apply +(for[i %](Math/pow i i)))
The input must be a list.
F# (.NET Core), 44 bytes
let s n=n|>Seq.map(fun n->pown n n)|>Seq.sum
Shorter than a Seq.mapFold. Explanation: As many other solutions, this takes a sequence as input, maps each entry to its self-exponent then sums over itself. In F#, the ** operator is limited to floats, so pown is required.
gnuplot 5.0, 40 bytes
f(a)=sum[j=1:words(a)](n=word(a,j),n**n)
There are neither arrays nor vectorized functions in gnuplot 5.0. Instead of an array a common workaround is to use a string with separators.
Funny enough, there is a sum function which is supposed to sum up a range, but it could also be used as an accumulator.
Excel, 13 Bytes
Takes input as a dynamic array from A1# and output to the calling cell.
=SUM(A1#^A1#)
For the input of ={4;6;7}, outputs 870455.
J-uby, 9 bytes
:sum+~:**
Expansion of J-uby code to standard Ruby:
:sum + ~:** # with spaces
->(a) {:sum.(a, &~:**)} # (F + G).(*args) == F.(*args, &G)
->(a) {:sum.(a, {|x| (~:**).(x)})} # definition of &
->(a) {:sum.(a, {|x| :**.(x, x)})} # (~F).(x) == F.(x,x)
->(a) {a.sum {|x| x ** x}} # :F.(x, y) == x.F(y)
excel, 34 bytes
=LET(a,TEXTSPLIT(A1,","),SUM(a^a))
if there's an array of integers in cell A1 separated by commas (without any zeroes), this should work i think.
Forth (gforth), 103 100 bytes
-3 bytes thanks to ovs
: ^ 1 TUCK +DO OVER * LOOP * ; : s 0 SWAP DUP @ 0 DO DUP I 1+ CELLS + @ DUP ^ ROT + SWAP LOOP DROP ;
No exponentiation in Forth so I first define ^ word and then the s word to compute the sum.
The idea:
addrTab
0 addrTab
\ enter the loop
0 addrTab addrElt1
0 addrTab Elt1
0 addrTab Elt1 Elt1
0 addrTab Elt1^Elt1
addTab 0+Elt1^Elt1
0+Elt1^Elt1 addrTab
...
0+Elt1^Elt1+...+EltN^EltN addrTab
\ exit the loop
0+Elt1^Elt1+...+EltN^EltN
Octave, 13 bytes
Simple anonymous function that raises an array to the power of itself on an element wise basis, then sums.
@(x)sum(x.^x)
Japt -mx, 2 bytes
pU
:Implicit map of each U in the input array
pU :Raise U to the power of U
:Implicit output of sum of resulting array
Retina, 30 bytes
~["L$`^¶$.("|""L$`.+
*$($&$*)_
Try it online! Explanation:
L$`.+
Loop over each input integer.
*$($&$*)_
Write that integer followed by a *, repeated (implicitly) that many times, then finally followed by a _. For example, 3 becomes 3*3*3*_, which is how you would calculate 3*3*3 in Retina.
|""
Join the calculations together, implicitly summing them.
["L$`^¶$.("
Turn the calculation into a command that replaces the input with the result of the calculation converted to decimal. (Retina 1 is clever enough not to actually do the calculation in unary if it knows that it will be converting the result to decimal.)
~`
Evaluate the resulting calculation.
For example, for inputs of 4, 6 and 7, the resulting calculation looks like this:
L$`^
$.(4*4*4*4*_6*6*6*6*6*6*_7*7*7*7*7*7*7*_
(The K command doesn't perform calculations so L$`^ is the easiest way.)
J, 5 bytes
1#.^~
^~, called with one argument, raises that argument to the power of itself. When that argument is an array the operation is applied to each cell.
1#. means "from base-1." As it turns out, interpreting a list of integers as the digits of a base-1 number is equivalent to summing them.
This is because #. in J doesn't care whether the digits it is given are greater than the base itself - it just treats them as any other digit, multiplying them by their place value, and summing the results. In this "base-1", the place value is always 1, so this is equivalent to just summing the array.
Thanks to Conor for showing me this trick, saving a byte over the more trivial +/@: I had earlier.
Julia 1.0, 12 bytes
~x=sum(x.^x)
This solution showcases how operations in Julia can be vectorized with a dot. I've redefined a single-character operator, but an anonymous function x->sum(x.^x) could also be used for the same score.
By the way, sum can accept a subfunction to be called on each element before summation. For example, if A is a vector, sum(sqrt.(x)) can be shortened to sum(sqrt,x). It's not helpful in this case, since there's no unary definition for ^, but this method has been useful for most of my solutions involving sum, often saving bytes over solutions involving count.
Brachylog, 7 bytes
{^↙?}ᵐ+
Rare use of ↙. There is a less elegant version also for 7 bytes: gjz^₎ᵐ+
Explanation
{ }ᵐ Map for each integer:
^ Raise to the power...
↙? ...of itself
+ Sum
C (gcc), 85 + 3 bytes (-lm)
main(c,v,j,t,i)char**v;{i=t=0;while(i<c)j=atoi(i++[v]),t+=pow(j,j);printf("%d",t-1);}
This is about the maximum I can optimize it without using Lambdas, which would probably make the code even longer without manual Assembly rewriting.
I wanted to use something different than printf(), but since itoa() for some reason isn't available, I couldn't swap it with puts() because it didn't support string formatting.
PowerShell Core, 33 bytes
-join($args|%{'+1'
"*$_"*$_})|iex
Builds the expression as a string, e.g.
+1*4*4*4*4+1*6*6*6*6*6*6+1*7*7*7*7*7*7*7
Then evaluate it
Pyth, 3 bytes
s^V
s^V
s # sum of
^V # vectorized power with itself using the (implicit) input-list twice
💎
Created with the help of Luminespire.
Google Sheets, 27 bytes
=sort(sum(if(A:A,A:A^A:A)))
Uses sort as an array enabler, and if() to weed out blanks. In Google Sheets, the numeric value of a blank is zero, and the self-exponents of a blank column would thus sum up to the number of rows in the column.

Bash, 29 bytes
for i;{
let t+=i**i
}
echo $t
use as a function or bash script. takes the array as an arbitrary number of arguments, outputs to stdout.
explanation:
for i;{ # in bash, if the 'in array' part is not provided to 'for elem in array', it implicitly loops over all arguments
let t+=i**i # bash variables are initialized to 0, the rest is simple enough
}
echo $t
Whitespace, 115 bytes
[S S S N
_Push_sum=0][N
S S N
_Create_Label_OUTER_LOOP][S N
S _Duplicate_sum][S N
S _Duplicate_sum][T N
T T _Read_STDIN_as_Integer][T T T _Retrieve_input][S N
S _Duplicate_input][N
T S T N
_If_0_Jump_to_Label_PRINT][S N
S _Duplicate_input][S N
S _Duplicate_input][N
S S S N
_Create_Label_INNER_LOOP][S S S T N
_Push_1][T S S T _Subtract_top_two][S N
S _Duplicate][N
T S S S N
_If_0_Jump_to_Label_RETURN][S N
T _Swap_top_two][S T S S T S N
_Copy_0-based_2nd_input_to_top][T S S N
_Multiply_top_two][S N
T _Swap_top_two][N
S N
S N
_Jump_to_INNER_LOOP][N
S S S S N
_Create_Label_RETURN][S N
N
_Discard_top_0][S N
T _Swap_top_two][S N
N
_Discard_top_input][T S S S _Add_top_two][N
S N
N
_Jump_to_OUTER_LOOP][N
S S T N
_Create_Label_PRINT][S N
N
_Discard_top_0][T N
S T _Print_as_Integer]
Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Since Whitespace can only read input one character/integer at a time, the input must contain a trailing 0 so we'll know when we're done reading inputs.
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Integer sum = 0
Start OUTER_LOOP:
Integer input = Read STDIN as integer
If (input == 0):
Stop OUTER_LOOP, and jump to PRINT
Integer product = input
Integer count = input
Start INNER_LOOP:
count = count - 1
If (count == 0):
Stop INNER_LOOP, and jump to RETURN
product = product * input
Go to next iteration of INNER_LOOP
RETURN:
sum = sum + product
Go to next iteration of OUTER_LOOP
PRINT:
Print sum as integer to STDOUT
(implicitly stop the program with an error: No exit defined)
Charcoal, 7 5 bytes
IΣXθθ
Try it online! Link is to verbose version of code.
θ Input array
X Vectorised raised to power
θ Input array
Σ Take the sum
I Cast to string
Implicitly print
Edit: Saved 2 bytes because I forgot that Power is one of the four (five on ATO) operators that auto-vectorises if both parameters are lists.
7 bytes to take input as a string:
IΣEAXιι
Try it online! Link is to verbose version of code. Explanation: Power auto-casts strings to integer, so I don't need to write Iι twice.
Vyxal s, 1 byte
e
Explanation:
e # Vectorized power with itself using the (implicit) input-list twice
s # Sum the list
# (after which the result is output implicitly)
05AB1E, 2 bytes
mO
Explanation:
m # Take the power of each value in the (implicit) input-list with each value in
# the (implicit) input-list at the same position
O # Sum those
# (after which this sum is output implicitly as result)
Wolfram Language (Mathematica), 8 bytes
Tr[#^#]&
Try it online! Unnamed function taking a list like {4, 6, 7} as input. The exponentiation operator ^ automatically distributes over arrays of the same length, and Tr of a one-dimensional list is its sum.
Arturo, 19 bytes
$=>[∑map&'x->x^x]
Explanation
$=>[] ; a function where input is assigned to &
∑ ; sum of...
map&'x-> ; map over input and assign current elt to x
x^x ; x to the x power
sed 4.2.2 -rz, 167 137 bytes
s!.*!sed -r 'h;G;:r;s/.\\n./\\n/;x;s/\\n.*//;t;:b;s/.*/\&\\n\&/m;:;t;x;s/^#//;x;tb;G;h;s/\\n(.)/\\1/g;T;s/\\n../\&/;tr'<<<'&'!e
s/\n..//g
This essentially calls a second instance of sed with a snipit of the script I used for this question to calculate the powers, and then concats everything together at the end.
Python 3.8 (pre-release), 29 26 bytes
-3 bytes thanks to Albert.Lang.
lambda l:sum(map(pow,l,l))
Explanation
lambda l: # Anonymous lambda
sum( ) # Sum of...
map(pow, ) # Exponentiation of...
l,l # element ** element for each element
Haskell, 17 bytes
sum.map((^)<*>id)
The (^)<*>id is point-free for \x->x^x. A list-comprehension solution is the same length.
f l=sum[x^x|x<-l]
Nibbles, 4 nibbles (2 bytes)
+.$^
+.$^ # full program
+x$^$$ # with implicit variables shown
+ # sum of
. # map over
$ # each element of input
^ # x to the power of y:
$ # x is each element
$ # y is each element
Jelly, 3 bytes
*`S
Explanation:
*`S
* Raise to
` its own [4,6,7] => [256, 46656, 823543]
S Sum [256, 46656, 823543] => 870455
