[Question]
  [
> 
> Tetration, represented as \${}^ba\$, is repeated exponentiation. For example, \${}^32\$ is \$2^{2^2}\$, which is \$16\$.
> 
> 
> 
Given two numbers \$a\$ and \$b\$, print \${}^ba\$.
## Test cases
```
1 2 -> 1
2 2 -> 4
5 2 -> 3125
3 3 -> 7625597484987
etc.
```
Scientific notation is acceptable.
Remember, this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the code with the smallest number of bytes wins.
  
[Answer]
# Dyalog APL, 3 bytes
```
*/⍴
```
[TryAPL.](http://tryapl.org/?a=f%u2190*/%u2374%20%u22C4%203%20f%202%20%u22C4%202%20f%203&run)
## Explanation
```
*/⍴  Input: b (LHS), a (RHS)
  ⍴  Create b copies of a
*/   Reduce from right-to-left using exponentation
```
[Answer]
# 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
```
[Answer]
## Python, 30 bytes
```
f=lambda a,b:b<1or a**f(a,b-1)
```
Uses the recursive definition.
[Answer]
## 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).(^)
```
[Answer]
# Mathematica, 16 bytes
```
Power@@Table@##&
```
# Explanation
```
Table@##
```
Make b copies of a.
```
Power@@...
```
Exponentiation.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
x*@/
```
[Try it online!](http://jelly.tryitonline.net/#code=eCpALw&input=&args=Mw+Mw) or [verify all test cases](http://jelly.tryitonline.net/#code=eCpALwrFvDsiw6ciRw&input=&args=MSwgMiwgNQ+MiwgMiwgMg).
### How it works
```
x*@/  Main link. Arguments: a, b
x     Repeat [a] b times.
 *@/  Reduce the resulting array by exponentation with swapped arguments.
```
[Answer]
# 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))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ ~~4~~ 2 bytes
*-2 thanks to [ovs](https://codegolf.stackexchange.com/users/64121/ovs).*
```
Gm
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fPff/f2MuYwA "05AB1E – 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
```
[Answer]
# 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
```
[Answer]
# R, 39 bytes
Recursive function:
```
f=function(a,b)ifelse(b>0,a^f(a,b-1),1)
```
[Answer]
# [Factor](https://factorcode.org/), ~~29~~ 26 bytes
```
[ 1 rot [ dupd ^ ] times ]
```
[Try it online!](https://tio.run/##TY6xCsJADIb3PsX/AgpWXBRcxcVFnEqF40zxaHt3Jiki0mevQR2aLH@@5E/SOK@Jp8v5eDps4USSF/RO72iJI3Vo@PWtl80QvYYUBV1QYtcJMpPqK3OICqHHQNGTURd4wcm3pNgVxbuAxRsrlBj/upzpzUyvLcdinCqb5qSocBvyDVfU0NDb7tpa8nTZgB3PSchc4@/vfW9c1Pl2Cd@R4@kD "Factor – Try It Online")
*-3 thanks to @Bubbler*
[Answer]
# [Element](http://github.com/PhiNotPi/Element), 11 bytes
```
__2:':1[^]`
```
[Try it online!](http://element.tryitonline.net/#code=X18yOic6MVteXWA&input=NQoy)
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
```
[Answer]
# 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
```
[Answer]
# dc, ~~35~~ 29 bytes:
```
?dsdsa?[ldla^sa1-d1<b]dsbxlap
```
Here is my first complete program in `dc`.
[Answer]
# PHP, 51 Bytes
```
for($b=$p=$argv[1];++$i<$argv[2];)$p=$b**$p;echo$p;
```
[Answer]
# GameMaker Language, ~~52~~ 50 bytes
```
d=a=argument0;for(c=1;c<b;c++)d=power(a,d)return d
```
[Answer]
# 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
[Answer]
# [Actually](http://github.com/Mego/Seriously), 6 bytes
```
n`ⁿ)`Y
```
[Try it online!](http://actually.tryitonline.net/#code=bmDigb8pYFk&input=Mwoz)
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)
```
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), 9 bytes
```
q~)*{\#}*
```
[Try it online!](http://cjam.tryitonline.net/#code=cX4pKntcI30q&input=WzUgMl0)
### 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
```
[Answer]
# [Wonder](https://github.com/wonderlang/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.
[Answer]
# [Flurry](https://github.com/Reconcyl/flurry) `-nii`, 14 bytes
```
{}{{}({})}{{}}
```
[Try it online!](https://bubbler-4.github.io/Flurry/#!ewB9AHsAewB9ACgAewB9ACkAfQB7AHsAfQB9AA==#MgAgADQA##bgBpAGkA#MQAwADAAMAAwAA==)
Takes two numbers `a b` from stdin, and outputs as the return value.
### How it works
It works basically like [xnor's Haskell answer](https://codegolf.stackexchange.com/a/97021/78410): 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
```
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 9 bytes
```
~])*{\?}*
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/vy5WU6s6xr5W6/9/YwVjAA "GolfScript – 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)`.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `r`, 4 bytes
This is lyxal's solution
```
‹(⁰e
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=r&code=%E2%80%B9%28%E2%81%B0e&inputs=3%0A3&header=&footer=)
```
‹(⁰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](https://github.com/Lyxal/Vyxal), ~~6~~ 5 bytes
Saved 1 byte thanks to lyxal
```
ʁ•⁽eḭ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%CA%81%E2%80%A2%E2%81%BDe%E1%B8%AD&inputs=3%0A%5B3%5D&header=&footer=)
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
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 7 bytes
```
(*/#)/#
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs9LQ0lfW1Ffm4kqLNrI2igVSxhDKBMYzjgUAo1gI6w==)
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](https://codegolf.stackexchange.com/q/5562/78410) because `4^(4^4)` is way too big to handle with built-in integer sizes.
[Answer]
# [Red](http://www.red-lang.org), ~~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!](https://tio.run/##K0pN@R@UmhIdy5Vm9T@tNC85OlEhKTa6wkohUSEnP79AIUlBV8EQwtfSUqiIjf1fUJSZV6KQpmCoYMQFYxshsU2R2MYKxv8B "Red – Try It Online")
[Answer]
# Pyth, 6 bytes
```
u^QGE1
```
[Try it online.](http://pyth.herokuapp.com/?code=u%5EQGE1&input=5%0A2&debug=0)
### Explanation
```
          (implicit: input a to Q)
     1    Start from 1.
u   E     b times,
 ^GQ      raise the previous number to power a.
        
```
[Answer]
## [Minkolang 0.15](https://github.com/elendiastarman/Minkolang), ~~12~~ 11 bytes
```
nnDI1-[;]N.
```
[Try it here!](http://play.starmaninnovations.com/minkolang/?code=nnDI1-%5B%3B%5DN%2E&input=3%203)
### 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.
```
[Answer]
## 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
```
[Answer]
# 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 `a`s with `b` elements, and apply `math.pow` from right to left. 
[Answer]
# TI-Basic, 19 bytes
```
Prompt A,B
A
For(C,2,B
A^Ans
End
```
]