# 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 , 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:

## 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(10)

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:

Introduced in 2007
(6.0)
{"ft_lang_label":"__label__en","ft_lang_prob":0.79590446,"math_prob":0.98147196,"size":1840,"snap":"2020-34-2020-40","text_gpt3_token_len":418,"char_repetition_ratio":0.2254902,"word_repetition_ratio":0.019933555,"special_character_ratio":0.20706522,"punctuation_ratio":0.10059172,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9988526,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,4,null,3,null,3,null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-20T18:40:05Z\",\"WARC-Record-ID\":\"<urn:uuid:912fecda-d413-4091-8ff2-f7270fe33e18>\",\"Content-Length\":\"116316\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bad24a7c-ee83-4fd4-86b2-1b04fcd57f7f>\",\"WARC-Concurrent-To\":\"<urn:uuid:74b89187-6c01-4c11-ac00-420c7c9d2c97>\",\"WARC-IP-Address\":\"140.177.205.163\",\"WARC-Target-URI\":\"https://reference.wolfram.com/language/ref/PrimePowerQ.html\",\"WARC-Payload-Digest\":\"sha1:VHPYZMAAIACHBLDIECFAN4G2XXD53OPG\",\"WARC-Block-Digest\":\"sha1:BDIQXROCBCGSK752BMVBBS265UF7L6YW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400198287.23_warc_CC-MAIN-20200920161009-20200920191009-00350.warc.gz\"}"}