OFFSET
1,2
COMMENTS
A self-inverse permutation of the natural numbers.
LINKS
Michael De Vlieger, Scatterplot of a(n), n = 1..1024, showing primes in red, composite prime powers in gold, squarefree composites in green, products of composite prime powers in magenta, and other numbers in blue. Powerful numbers are labeled unless they are less than 32.
FORMULA
a(a(n)) = n.
a(prime(k)^(p-1)) = prime(k-1)^(p-1) for even k and prime p else prime(k+1)^(p-1). - Michael De Vlieger, Dec 20 2022
EXAMPLE
a(16) = 81 because this is the smallest unused k != 16, having the same number (5) of divisors as 16.
MATHEMATICA
nn = 68; c[_] = False; a[1] = 1; c[1] = True; u = 2; Do[Set[{k, t}, {u, DivisorSigma[0, n]}]; While[Or[c[k], k == n, t != DivisorSigma[0, k]], k++]; Set[{a[n], c[k]}, {k, True}]; If[k == u, While[c[u], u++]], {n, 2, nn}]; Array[a, nn] (* Michael De Vlieger, Dec 20 2022 *)
PROG
(Python)
from functools import lru_cache
from sympy import divisor_count
from itertools import count, islice
@lru_cache(maxsize=None)
def d(n): return divisor_count(n)
def agen():
mink, seen = 2, {1}
yield 1
for n in count(2):
k = mink
while k == n or k in seen or d(k) != d(n): k += 1
while mink in seen: mink += 1
yield k
seen.add(k)
print(list(islice(agen(), 68))) # Michael S. Branicky, Dec 13 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore, Dec 13 2022
EXTENSIONS
More terms from Michael S. Branicky, Dec 13 2022
STATUS
approved