login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(1) = 1. Thereafter a(n) is the least unused k distinct from n such that d(k) = d(n), where d is the divisor counting function, A000005.
1

%I #19 Feb 22 2024 20:06:07

%S 1,3,2,9,7,8,5,6,4,14,13,18,11,10,21,81,19,12,17,28,15,26,29,30,49,22,

%T 33,20,23,24,37,44,27,35,34,100,31,39,38,42,43,40,41,32,50,51,53,80,

%U 25,45,46,63,47,56,57,54,55,62,61,72,59,58,52,729,69,70,71,75

%N a(1) = 1. Thereafter a(n) is the least unused k distinct from n such that d(k) = d(n), where d is the divisor counting function, A000005.

%C A self-inverse permutation of the natural numbers.

%H Michael De Vlieger, <a href="/A359036/a359036.png">Scatterplot of a(n)</a>, 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.

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(a(n)) = n.

%F 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

%e a(16) = 81 because this is the smallest unused k != 16, having the same number (5) of divisors as 16.

%t 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 *)

%o (Python)

%o from functools import lru_cache

%o from sympy import divisor_count

%o from itertools import count, islice

%o @lru_cache(maxsize=None)

%o def d(n): return divisor_count(n)

%o def agen():

%o mink, seen = 2, {1}

%o yield 1

%o for n in count(2):

%o k = mink

%o while k == n or k in seen or d(k) != d(n): k += 1

%o while mink in seen: mink += 1

%o yield k

%o seen.add(k)

%o print(list(islice(agen(), 68))) # _Michael S. Branicky_, Dec 13 2022

%Y Cf. A000005, A005179, A358820.

%K nonn

%O 1,2

%A _David James Sycamore_, Dec 13 2022

%E More terms from _Michael S. Branicky_, Dec 13 2022