2g: Unsigned Powers

+pow

Computes .a raised to the power of .b, producing an $atom.

Accepts

.a is an $atom.

.b is an $atom.

Produces

An $atom.

Source

++  pow
  ~/  %pow
  |=  [a=@ b=@]
  ?:  =(b 0)  1
  |-  ?:  =(b 1)  a
  =+  c=$(b (div b 2))
  =+  d=(mul c c)
  ?~  (dis b 1)  d  (mul d a)

Examples


+sqt

Computes the square root of .a and its remainder.

Accepts

.a is an $atom.

Produces

A cell of $atoms.

Source

Examples


Last updated