10.11 RootInt

RootInt( n )
RootInt( n, k )

RootInt returns the integer part of the kth root of the integer n. If the optional integer argument k is not given it defaults to 2, i.e., RootInt returns the integer part of the square root in this case.

If n is positive RootInt returns the largest positive integer r such that r^k <= n. If n is negative and k is odd RootInt returns -RootInt( -n, k ). If n is negative and k is even RootInt will cause an error. RootInt will also cause an error if k is 0 or negative.

    gap> RootInt( 361 );
    19
    gap> RootInt( 2 * 10^12 );
    1414213
    gap> RootInt( 17000, 5 );
    7        # $7^5 = 16807$ 

Previous Up Top Next
Index

GAP 3.4.4
April 1997