g | x | w | all
Bytes Lang Time Link
029AWK241202T192840Zxrs
016Juby240921T191255ZJordan
003Uiua240921T172747Znyxbird
016Raku230813T102637ZSean
003Thunno 2 t230813T094225ZThe Thon
037Red210604T143851ZAaroneou
007K ngn/k210609T061601ZBubbler
026Factor210529T224415Zchunes
004Vyxal r210530T222438Zuser
00205AB1E200923T001212ZMakonede
009GolfScript200922T215047Z2014MELO
014Flurry nii200824T043807ZBubbler
027Funky171029T221925ZATaco
050GameMaker Language161022T150926ZTimtech
056Clojure161223T132928ZNikoNyrh
021Wonder161203T221304ZMama Fun
070Axiom161118T082841Zuser5898
068Powershell161118T164949Zcolsw
050Bash161118T105728Zzeppelin
050C161114T010226ZKarl Nap
057Java 7161025T090924ZKevin Cr
019TIBasic161022T150558ZTimtech
051PHP161022T175758ZJör
009CJam161022T151147ZLuis Men
039R161022T141821ZBillywob
045Scala161022T124057Zcorvus_1
019Perl161022T065457ZTon Hosp
006Actually161022T051448Zuser4594
051Racket161022T044553Zrnso
029dc161022T025645ZR. Kap
004Jelly161022T011042ZDennis
016Mathematica161022T030306ZJungHwan
011Minkolang 0.15161022T013419ZEl'e
033Python161022T004713ZDJMcMayh
006Pyth161022T011902ZPurkkaKo
024JavaScript ES7161022T011902ZETHprodu
003Dyalog APL161022T011744Zmiles
004J161022T010155Zmiles
011Element161022T010324ZPhiNotPi
040Perl161022T010231ZGabriel
019Haskell161022T004758Zxnor
030Python161022T004925Zxnor

AWK, 29 bytes

{for(x=$1;++i<$2;)x=$1^x}$0=x

Attempt This Online!

J-uby, 16 bytes

Takes reversed arguments.

~:*%-[I]|:/&~:**

Attempt This Online!

Uiua, 3 bytes

/ⁿ↯

Try it!

Takes reversed inputs (appending : flip removes this).

↯ reshape a into length b, and / reduce with ⁿ power.

Raku, 16 bytes

{[**] $^a xx$^b}

Try it online!

$^a and $^b are the arguments to this anonymous function. $^a xx $^b is a list of the first argument replicated a number of times given by the second argument. [**] reduces that list with the exponentiation operator. The reduction respects the right-associativity of the operator.

Thunno 2 t, 3 bytes

ọƲ@

Try it online!

Explanation

ọƲ@  # Implicit input
ọ    # Repeat [a] b times
 Ʋ   # Reduce the list by:
  @  #  Swapped exponentiation
     # Implicit output

Red, 38 26 37 bytes

Thanks to @9214 for telling me about the loop command for -12 bytes.

+11 bytes to fix invalidities brought out by @Bubbler.

func[a b][x: a loop b - 1[x: a ** x]]

Try it online!

K (ngn/k), 7 bytes

(*/#)/#

Try it online!

Takes two inputs in the order of [hyperexponent; base] and returns the result.

K does not have exponentiation built-in, so I simulate n^m with "product */ of m copies # of n" instead. Tetration is basically the same, in the sense that it is a fold by exponentiation. K's fold is left to right, and */# accepts [exponent; base], so the direction of exponentiation is correctly y^(y^(y^...)).

Although it does not use exponentiation built-in, it fails to solve this challenge because 4^(4^4) is way too big to handle with built-in integer sizes.

Factor, 29 26 bytes

[ 1 rot [ dupd ^ ] times ]

Try it online!

-3 thanks to @Bubbler

Vyxal r, 4 bytes

This is lyxal's solution

‹(⁰e

Try it Online!

‹(⁰e
‹     Decrement b
 (  ) For loop (second parentheses is implicit) using b-1
  ⁰   Push a
   e  And raise it to the power of the accumulator (initially a)

Vyxal, 6 5 bytes

Saved 1 byte thanks to lyxal

ʁ•⁽eḭ

Try it Online!

This one is a worse solution. a is inputted as a singleton list.

ʁ•λe;ḭ
ʁ      Make a range [0,b) (only the length of the range matters (b))
 •     Reshape [a] to that (make a list of b a's)
     ḭ Reduce from the right
  λe;  using exponentiation

05AB1E, 9 4 2 bytes

-2 thanks to ovs.

Gm

Try it online! Beats all other answers

Gm  # full program
G   # for N in [1, 2, 3, ...,
    # ..., implicit input...
G   # ...minus 1]...
 m  # push...
    # implicit input...
 m  # to the power of...
    # implicit input...
    # (implicit) or top of stack if not first iteration
    # implicit output

GolfScript, 9 bytes

~])*{\?}*

Try it online!

~]          # Put a and b in an array
  )         # Remove b from the array
   *        # Make b copies of a
    {  }*   # Execute this block for each number in the array
     \?     # Exponentiation

Just {?} would be (3^3)^3 instead of 3^(3^3).

Flurry -nii, 14 bytes

{}{{}({})}{{}}

Try it online!

Takes two numbers a b from stdin, and outputs as the return value.

How it works

It works basically like xnor's Haskell answer: repeat (a^) b times to 1. a is left on the stack, so that it can be referenced in each iteration.

// In Church numeral, x a → a^x
main = b power_of_a 1

power_of_a = \x. x a
           = \x. x (push pop)  // assumes a is on the top of the stack,
                               // pops and takes its value and pushes it back

Funky, 27 bytes

f=(a,b)=>(b<2)?a:a^f(a,b-1)

Try it online!

GameMaker Language, 52 50 bytes

d=a=argument0;for(c=1;c<b;c++)d=power(a,d)return d

Clojure, 56 bytes

(fn[a b](last(take a(iterate #(apply *(repeat % b))b))))

Maybe there is a shorter way via apply comp?

Wonder, 21 bytes

f\@@[#0?^#1f#1-#0 1?1

Uses the recursive approach. Usage:

f\@@[#0?^#1f#1-#0 1?1];f 2 3

Bonus solution, 22 bytes

@@:^ -#0 1(genc ^#1)#1

A slightly unconventional approach. Usage:

t\@@+>#[^;#1]tk -#0 1rpt#1;t 2 3

More readable:

@@
  iget
    - #0 1
    (genc ^#1) #1

Assuming a^^b:

Generates an infinite list of tetrated a; for a=2, this list would look something like [2 4 16 65536...]. Then indexes at b-1 because Wonder is zero-indexed.

Axiom 70 bytes

l(a,b)==(local i;i:=1;r:=a;repeat(if i>=b then break;r:=a^r;i:=i+1);r)

this less golfed

l(a,b)==
  local i
  i:=1;r:=a;repeat(if i>=b then break;r:=a^r;i:=i+1)
  r


(3) ->  [l(1,2),l(2,2),l(5,2),l(3,3),l(4,3)]

     (3)
     [1, 4, 3125, 7625597484987,
      13407807929942597099574024998205846127479365820592393377723561443721764030_
       0735469768018742981669034276900318581864860508537538828119465699464336490_
       06084096
       ]
                                                   Type: List PositiveInteger

Powershell, 68 Bytes

filter p ($a){[math]::Pow($a,$_)};iex (,$args[0]*$args[1]-join"|p ")

This is the shortest of the three approaches I tried, not that great overall though, i'm 100% sure there's a shorter approach but the few things I tried somehow ended up with slightly more bytes.

PS C:\++\golf> (1,2),(2,2),(5,2),(3,3) | % {.\sqsq $_[0] $_[1]}
1
4
3125
7625597484987

Sadly Powershell has no built-in ^ or ** operator, or it would be a clean 32/33 byte answer, i.e.

iex (,$args[0]*$args[1]-join"^")

Bash, 50 bytes

(within the bounds of bash integer data type)

Golfed

E() { echo $(($(printf "$1**%.0s" `seq 1 $2`)1));}

Explanation

Build expression with printf, e.g. E 2 5:

  2**2**2**2**2**1

then use bash built-in arithmetic expansion to compute the result

Test

E 1 2
1

E 2 2
4

E 5 2
3125

E 3 3
7625597484987

C, 50 bytes

double t(int x,int n){return n?pow(x,t(x,n-1)):1;}

Straightforward from the definition of Tetration.

Java 7, 71 57 bytes

double c(int a,int b){return b>0?Math.pow(a,c(a,b-1)):1;}

Ungolfed & test code:

Try it here.

class M{
  static double c(int a, int b){
    return b > 0
            ? Math.pow(a, c(a, b-1))
            :1;
  }

  public static void main(String[] a){
    System.out.println(c(1, 2));
    System.out.println(c(2, 2));
    System.out.println(c(5, 2));
    System.out.println(c(3, 3));
  }
}

Output:

1.0
4.0
3125.0
7.625597484987E12

TI-Basic, 19 bytes

Prompt A,B
A
For(C,2,B
A^Ans
End

PHP, 51 Bytes

for($b=$p=$argv[1];++$i<$argv[2];)$p=$b**$p;echo$p;

CJam, 9 bytes

q~)*{\#}*

Try it online!

Explanation

q~          e# Take input (array) and evaluate
  )         e# Pull off last element
   *        e# Array with the first element repeated as many times as the second
    {  }*   e# Reduce array by this function
     \#     e# Swap, power

R, 39 bytes

Recursive function:

f=function(a,b)ifelse(b>0,a^f(a,b-1),1)

Scala, 45 bytes

Seq.fill(_:Int)(_:Double)reduceRight math.pow

Ungolfed:

(a:Int,b:Double)=>Seq.fill(a)(b).reduceRight(math.pow)

Build a sequence of as with b elements, and apply math.pow from right to left.

Perl, 19 bytes

Includes +1 for -p

Give numbers on separate lines on STDIN

tetration.pl
2
3
^D

tetration.pl

#!/usr/bin/perl -p
$_=eval"$_**"x<>.1

Actually, 6 bytes

n`ⁿ)`Y

Try it online!

Input is taken as b\na (\n is a newline)

Explanation:

n`ⁿ)`Y
n       a copies of b
 `ⁿ)`Y  while stack changes between each call (fixed-point combinator):
  ⁿ       pow
   )      move top of stack to bottom (for right-associativity)

Racket 51 bytes

(define ans 1)(for((i b))(set! ans(expt a ans)))ans

Ungolfed:

(define (f a b)
  (define ans 1)
  (for((i b))
    (set! ans
          (expt a ans)))
  ans)

Testing:

(f 1 2)
(f 2 2)
(f 5 2)
(f 3 3)

Output:

1
4
3125
7625597484987

dc, 35 29 bytes:

?dsdsa?[ldla^sa1-d1<b]dsbxlap

Here is my first complete program in dc.

Jelly, 4 bytes

x*@/

Try it online! or verify all test cases.

How it works

x*@/  Main link. Arguments: a, b

x     Repeat [a] b times.
 *@/  Reduce the resulting array by exponentation with swapped arguments.

Mathematica, 16 bytes

Power@@Table@##&

Explanation

Table@##

Make b copies of a.

Power@@...

Exponentiation.

Minkolang 0.15, 12 11 bytes

nnDI1-[;]N.

Try it here!

Explanation

nn             Read two integers from input
  D            Pop top of stack and duplicate next element that many times
   I1-         Push length of stack, minus 1
      [        Pop top of stack and repeat for loop that many times
       ;       Pop b, a and push a^b
        ]      Close for loop
         N.    Output as number and stop.

Python, 33 bytes

lambda a,b:eval('**'.join([a]*b))

This evaluates to an unnamed function, that takes the string representation of a number and a number. For example:

>>> f=lambda a,b:eval('**'.join([a]*b))
>>> f('5',2)
3125
>>>

If mixing input formats like this does not count, there is also this 38 byte version:

lambda a,b:eval('**'.join([str(a)]*b))

Pyth, 6 bytes

u^QGE1

Try it online.

Explanation

          (implicit: input a to Q)
     1    Start from 1.
u   E     b times,
 ^GQ      raise the previous number to power a.
        

JavaScript (ES7), 24 bytes

f=(a,b)=>b?a**f(a,b-1):1

The ES6 version is 33 bytes:

f=(a,b)=>b?Math.pow(a,f(a,b-1)):1

Dyalog APL, 3 bytes

*/⍴

TryAPL.

Explanation

*/⍴  Input: b (LHS), a (RHS)
  ⍴  Create b copies of a
*/   Reduce from right-to-left using exponentation

J, 5 4 bytes

^/@#

This is literally the definition of tetration.

Usage

   f =: ^/@#
   3 f 2
16
   2 f 1
1
   2 f 2
4
   2 f 5
3125
   4 f 2
65536

Explanation

^/@#  Input: b (LHS), a (RHS)
   #  Make b copies of a
^/@   Reduce from right-to-left using exponentation

Element, 11 bytes

__2:':1[^]`

Try it online!

This is just "straightforward" exponentiation in a loop.

__2:':1[^]`
__              take two values as input (x and y)
  2:'           duplicate y and send one copy to the control stack
     :          make y copies of x
      1         push 1 as the initial value
       [ ]      loop y times
        ^       exponentiate
          `     print result

Perl, 40 bytes

map{$a=$ARGV[0]**$a}0..$ARGV[1];print$a;

Accepts two integers as input to the function and outputs the result

Haskell, 19 bytes

a%b=iterate(a^)1!!b

Iterates exponentiating starting at 1 to produce the list [1,a,a^a,a^a^a,...], then take the b'th element.

Same length directly:

a%0=1;a%b=a^a%(b-1)

Point-free is longer:

(!!).(`iterate`1).(^)

Python, 30 bytes

f=lambda a,b:b<1or a**f(a,b-1)

Uses the recursive definition.