commands → root

root(A,B)
root(A,B,0)
root(A,B,P)

The root command computes A^(1/B) where A and B are numeric. If a third argument P is given it is the modulus and we solve X^B = A mod P. If P is zero then root computes the integer floor of A^(1/B).

Examples

root(16,2);
	4.

root(24,3,0);
	2

# 3 = x^5 mod 13
root(3,5,13);
	9

(9^5) % 13;
	3

References

Gullberg, Jan. Mathematics: From the Birth of Numbers. Norton, 1996.