login
If n is a power of 2, a(n) = n. Otherwise, if 2^j is the greatest power of 2 not exceeding n, and if k = n - 2^j, then a(n) is the smallest m*a(k) which has not occurred already, where m is an odd number.
1

%I #38 Oct 02 2022 10:33:30

%S 1,2,3,4,5,6,9,8,7,10,15,12,25,18,27,16,11,14,21,20,35,30,45,24,49,50,

%T 75,36,125,54,81,32,13,22,33,28,55,42,63,40,77,70,105,60,175,90,135,

%U 48,99,98,147,100,245,150,225,72,343,250,375,108,625,162,243,64,17

%N If n is a power of 2, a(n) = n. Otherwise, if 2^j is the greatest power of 2 not exceeding n, and if k = n - 2^j, then a(n) is the smallest m*a(k) which has not occurred already, where m is an odd number.

%C The definition implies that if n is not a power of 2, then neither is a(n).

%C Similar to the Doudna sequence (A005940), except that here the multiple of a(k) used to compute a(n) is the least odd number (rather than the least odd prime), such that a(n) is a novel term. Terms are the same as in A005940 until a(49)=99 (instead of 121), subsequent to which further odd nonprime multiples produce more differences from A005940; the next is a(71)=117 (instead of 99).

%C A permutation of the positive integers, in which the primes appear in natural order, but the odd numbers do not (9 precedes 7, 25 precedes 21, etc.).

%H Michael De Vlieger, <a href="/A357268/b357268.txt">Table of n, a(n) for n = 1..16384</a>

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

%F a(2^n + 1) is the smallest odd number which has not already occurred.

%e n = 49 = 2^5 + 17, and a(17) = 11, so a(49) is the least m*a(17) which has not occurred earlier, where m is an odd number. Up to this point we have seen 3*11, 5*11, 7*11, but not 9*11. Therefore a(49) = 9*11 = 99 (compare with A005940(71)=99).

%t nn = 65; m = 1; c[_] = False; Do[Set[{m, k}, {1, n - 2^Floor[Log2[n]]}]; If[k == 0, Set[{a[n], c[n]}, {n, True}], While[Set[t, m a[k]]; Or[m == 1, c[t]], m += 2]; Set[{a[n], c[t]}, {t, True}]], {n, nn}]; Array[a, nn] (* _Michael De Vlieger_, Sep 21 2022 *)

%o (Python)

%o from sympy import nextprime

%o from sympy.ntheory import digits

%o from itertools import count, islice

%o def b(n): return n - 2**(len(bin(n)[2:]) - 1)

%o def agen():

%o aset, alst = set(), [None]

%o for n in count(1):

%o k = b(n)

%o if k == 0: an = n

%o else:

%o ak, p = alst[k], 3

%o while p*ak in aset: p += 2

%o an = p*ak

%o yield an; aset.add(an); alst.append(an)

%o print(list(islice(agen(), 65))) # _Michael S. Branicky_, Sep 21 2022

%o (PARI) f(n) = n - 2^(logint(n, 2)); \\ A053645

%o lista(nn) = {my(va = vector(nn), sa = Set(va)); for (n=1, nn, my(x = f(n)); if (x == 0, va[n] = n, my(k=1); while (setsearch(sa, k*va[x]), k+=2); va[n] = k*va[x];); sa = Set(va);); va;} \\ _Michel Marcus_, Sep 27 2022

%Y Cf. A005940, A356867, A356886.

%Y Cf. A053644, A053645.

%K nonn

%O 1,2

%A _David James Sycamore_, Sep 21 2022