10.17 IsPrimePowerInt

IsPrimePowerInt( n )

IsPrimePowerInt returns true if the integer n is a prime power and false otherwise.

n is a prime power if there exists a prime p and a positive integer i such that p^i = n. If n is negative the condition is that there must exist a negative prime p and an odd positive integer i such that p^i = n. 1 and -1 are not prime powers.

Note that IsPrimePowerInt uses SmallestRootInt (see SmallestRootInt) and a probable-primality test (see IsPrimeInt).

    gap> IsPrimePowerInt( 31^5 );
    true
    gap> IsPrimePowerInt( 2^31-1 );
    true        # $2^{31}-1$ is actually a prime
    gap> IsPrimePowerInt( 2^63-1 );
    false
    gap> Filtered( [-10..10], IsPrimePowerInt );
    [ -8, -7, -5, -3, -2, 2, 3, 4, 5, 7, 8, 9 ] 

Previous Up Top Next
Index

GAP 3.4.4
April 1997