Function Repository Resource:

PerfectPower

Source Notebook

Find all perfect power representations of an integer

Contributed by: Swastik Banerjee

ResourceFunction["PerfectPower"][n]

gives a list of all nontrivial integer base and exponent pairs that equal n.

Details and Options

An integer base and exponent represent another integer nontrivially if both base and exponent are greater than one.
An integer has a perfect power if the set of exponents in its prime factorization have a GCD greater than one.
ResourceFunction["PerfectPower"] returns a List of all pairs {xi,ki} with xi>1 and ki>1 such that n=xik1. If there are no such representations, it returns an empty List.

Examples

Basic Examples (1) 

Integer base and exponent pairs that can be used to represent 16 as a perfect power:

In[1]:=
ResourceFunction["PerfectPower"][16]
Out[1]=

Scope (2) 

Find all numbers less than or equal to 105 that can be represented as perfect powers of exactly three numbers:

In[2]:=
For[i = 2, i <= 10^5, i++, If[Length[ResourceFunction["PerfectPower"][i]] == 3, Print[i, " ", ResourceFunction["PerfectPower"][i]]]]

Yet another example with a large number:

In[3]:=
ResourceFunction["PerfectPower"][10^2000 + 5]
Out[3]=

Applications (1) 

Many of Pillai's conjectures or Catalan's proof can be investigated and verified using PerfectPower. Investigating solutions for the Catalan equation:

In[4]:=
For[i = 2, i <= 10000, i++, If[Length[ResourceFunction["PerfectPower"][i]] >= 1 && Length[ResourceFunction["PerfectPower"][i + 1]] >= 1, Print[{i, i + 1}]]]

Properties and Relations (1) 

PerfectPower of primes always returns an empty List:

In[5]:=
ResourceFunction["PerfectPower"][13]
Out[5]=

Possible Issues (1) 

PerfectPower[n] returns unevaluated n is negative:

In[6]:=
ResourceFunction["PerfectPower"][-8]
Out[6]=

Neat Examples (2) 

1267650600228229401496703205376 decomposed into perfect powers of integers:

In[7]:=
ResourceFunction["PerfectPower"][1267650600228229401496703205376]
Out[7]=

PerfectPower representations of a fairly large number:

In[8]:=
ResourceFunction[
 "PerfectPower"][278852867695983428743551899626170741344320007406576756809393190515479166707271366902794763772978174075895250849193986753985016903685127205588186040257189228351290693708134117612912814050283582240005547538013970502446610802398122213376]
Out[8]=

Publisher

Wolfram Summer School

Version History

  • 1.0.0 – 25 September 2020

Source Metadata

Related Resources

License Information