Integer Roots (GNU MP 6.3.0)
Description: How to install and use the GNU multiple precision arithmetic library, version 6.3.0.

### 5.8 Root Extraction Functions

Function: `int` mpz_root `(mpz_t rop, const mpz_t op, unsigned long int n)` ¶

  Set rop to the truncated integer part of the nth root of op. Return non-zero if the computation was exact, i.e., if op is rop to the nth power.

Function: `void` mpz_rootrem `(mpz_t root, mpz_t rem, const mpz_t u, unsigned long int n)` ¶

  Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u−root**n.

Function: `void` mpz_sqrt `(mpz_t rop, const mpz_t op)` ¶

  Set rop to the truncated integer part of the square root of op.

Function: `void` mpz_sqrtrem `(mpz_t rop1, mpz_t rop2, const mpz_t op)` ¶

  Set rop1 to the truncated integer part of the square root of op, like `mpz_sqrt`. Set rop2 to the remainder op−rop1*rop1, which will be zero if op is a perfect square.

  If rop1 and rop2 are the same variable, the results are undefined.

Function: `int` mpz_perfect_power_p `(const mpz_t op)` ¶

  Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b>1, such that op equals a raised to the power b.

  Under this definition both 0 and 1 are considered to be perfect powers. Negative values of op are accepted, but of course can only be odd perfect powers.

Function: `int` mpz_perfect_square_p `(const mpz_t op)` ¶

  Return non-zero if op is a perfect square, i.e., if the square root of op is an integer. Under this definition both 0 and 1 are considered to be perfect squares.