Algorithm to solve equations such as $\varphi(n)=x$

249 Views Asked by At

I want to write some code that inverts Euler's totient, so solving the equation:

$$\varphi(n)=x$$

where $x$ is known.

Before reinventing the wheel, I googled around to see if there was already something, and I was quite amazed to find nothing. Maybe I was somehow naive - that's an option. Is there some well known algorithm performing this task? If not, is there a specific reason why?

Best,

K.

1

There are 1 best solutions below

0
On

Another reason there is no discussion of an inverse of Euler's totient function is that it is not injective, therefore possesses no inverse. Here are all numbers $n \geq 1$ with $\phi(n) \leq 52,$ with $\phi(n)$ printed first on each line. Such a list is finite, as $$ \sqrt \frac{n}{2} \leq \phi(n) \leq n $$

phi(n)         n
   1           1
   1           2

   2           3
   2           4
   2           6

   4          10
   4          12
   4           5
   4           8

   6          14
   6          18
   6           7
   6           9

   8          15
   8          16
   8          20
   8          24
   8          30

  10          11
  10          22

  12          13
  12          21
  12          26
  12          28
  12          36
  12          42

  16          17
  16          32
  16          34
  16          40
  16          48
  16          60

  18          19
  18          27
  18          38
  18          54

  20          25
  20          33
  20          44
  20          50
  20          66

  22          23
  22          46

  24          35
  24          39
  24          45
  24          52
  24          56
  24          70
  24          72
  24          78
  24          84
  24          90

  28          29
  28          58

  30          31
  30          62

  32         102
  32         120
  32          51
  32          64
  32          68
  32          80
  32          96

  36         108
  36         114
  36         126
  36          37
  36          57
  36          63
  36          74
  36          76

  40         100
  40         110
  40         132
  40         150
  40          41
  40          55
  40          75
  40          82
  40          88

  42          43
  42          49
  42          86
  42          98

  44         138
  44          69
  44          92

  46          47
  46          94

  48         104
  48         105
  48         112
  48         130
  48         140
  48         144
  48         156
  48         168
  48         180
  48         210
  48          65

  52         106
  52          53

phi(n)         n