PrimePowerQ

PrimePowerQ[expr]

yields True if expr is a power of a prime number, and yields False otherwise.

Details and Options

  • PrimePowerQ is typically used to test whether a number is a power of a prime number.
  • A prime power is a prime or an integer power of a prime.
  • PrimePowerQ[n] returns True unless n is manifestly a prime power.
  • With the setting GaussianIntegers->True, PrimePowerQ tests whether a number is a Gaussian prime power.
  • PrimePowerQ[m+In] automatically works over Gaussian integers.

Examples

open allclose all

Basic Examples  (2)

Test whether a number is a prime power:

The number 6 is not a prime power:

Scope  (5)

PrimePowerQ works over integers:

Gaussian integers:

Rational numbers:

Test for large integers:

PrimePowerQ threads over lists:

Applications  (10)

Basic Applications  (4)

Highlight prime powers:

Generate random prime powers:

Gaussian prime powers:

The first few prime powers that are not prime:

Number Theory  (6)

Recognize Mersenne numbers, integers that have the form :

The number is a Mersenne number; is not:

The infinite sum of reciprocals of prime powers that are not prime converges:

The number of elements in a finite field is a prime power:

Compute the number of irreducible polynomials of degree n over a finite field of order q:

Compute for degree 5 and order 9:

The number of prime powers in intervals of size 1000:

A visualization of the growth of the prime powers:

The distribution of prime powers over integers:

Plot the distribution:

The distribution of Gaussian prime powers:

Plot the distribution:

Properties & Relations  (11)

Prime powers are divisible by exactly one prime number:

The prime factorization of a prime power:

PrimePowerQ gives True for all prime numbers:

The only square-free prime powers are prime numbers:

Use PrimeNu to count the number of distinct divisors:

If PrimeNu returns 1, the number is a prime power:

PrimeOmega gives the exponent for a prime power:

MoebiusMu gives 0 for composite prime powers and for primes:

Use FactorInteger to test for prime powers:

Use MangoldtLambda to test for a prime power:

Primes that are congruent to 1 mod 4 are not prime powers in the Gaussian integers:

The sum of divisors of a prime power n is less than 2n:

Neat Examples  (2)

Plot the prime powers that are the sum of three squares:

Plot the Ulam spiral, where numbers are colored based on whether they are a prime power:

Wolfram Research (2007), PrimePowerQ, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimePowerQ.html.

Text

Wolfram Research (2007), PrimePowerQ, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimePowerQ.html.

CMS

Wolfram Language. 2007. "PrimePowerQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PrimePowerQ.html.

APA

Wolfram Language. (2007). PrimePowerQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PrimePowerQ.html

BibTeX

@misc{reference.wolfram_2024_primepowerq, author="Wolfram Research", title="{PrimePowerQ}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/PrimePowerQ.html}", note=[Accessed: 01-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_primepowerq, organization={Wolfram Research}, title={PrimePowerQ}, year={2007}, url={https://reference.wolfram.com/language/ref/PrimePowerQ.html}, note=[Accessed: 01-December-2024 ]}