Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the list of integers whose Euler totients are equal to a given value
ResourceFunction["EulerPhiInverse"][n] lists the integers m such that EulerPhi[m]=n. | |
ResourceFunction["EulerPhiInverse"][n,k] lists the integers m such that EulerPhi[m]= n up to k terms. |
Find all integers m such that ϕ(m)=1000:
| In[1]:= |
| Out[1]= |
Check:
| In[2]:= |
| Out[2]= |
Find all 6535 integers m such that ϕ(m)=1020:
| In[3]:= |
| Out[3]= |
| In[4]:= |
| Out[4]= |
| In[5]:= |
| Out[5]= |
Verify that these are the correct solutions:
| In[6]:= |
| Out[6]= |
It takes only a fraction of second to find all solution for the numbers below on a modern computer:
| In[7]:= |
| Out[7]= |
| In[8]:= |
| Out[8]= |
EulerPhiInverse returns an empty list for all odd integer except 1:
| In[9]:= |
| Out[9]= |
List non-totients:
| In[10]:= |
| Out[10]= | ![]() |
Show that non-totients have no preimage under Euler's totient function:
| In[11]:= |
| Out[11]= |
EulerPhiInverse only handles positive integers. Otherwise, it returns unevaluated:
| In[12]:= |
| Out[12]= |
The number of solutions may grow rapidly for those inputs with prime factors p such that p-1 is highly composite:
| In[13]:= |
| Out[13]= |
Increase the second argument to get all solutions for x such that EulerPhi[x]=1028:
| In[14]:= |
| Out[14]= |
Numbers k such that EulerPhi[x]=k has exactly 2 solutions (OEIS A007366):
| In[15]:= |
| Out[16]= |
| In[17]:= |
| Out[17]= | ![]() |
Visualize the data:
| In[18]:= |
| Out[18]= | ![]() |
A pair of dual graph: n→ϕ(n) on the right and n→ m for ϕ(m) =n on the left:
| In[19]:= | ![]() |
| Out[20]= | ![]() |
The graph on the left hand side seems denser than the right because the inverse of ϕ is a multivalued function:
| In[21]:= |
| Out[21]= |
Number of integers k such that EulerPhi[k]=n (OEIS A072074):
| In[22]:= |
| Out[23]= |
| In[24]:= |
| Out[24]= | ![]() |
Plot the data and its logarithm approximation:
| In[25]:= |
| In[26]:= |
| Out[26]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License