login
A285111
Permutation of nonnegative integers: a(1) = 0, a(2) = 1, a(A005117(1+n)) = 2*a(n), a(A065642(n)) = 1 + 2*a(n).
5
0, 1, 2, 3, 4, 6, 8, 7, 5, 12, 16, 13, 14, 10, 24, 15, 32, 27, 26, 25, 28, 20, 48, 55, 9, 30, 11, 21, 64, 54, 52, 31, 50, 56, 40, 111, 96, 110, 18, 51, 60, 22, 42, 41, 49, 128, 108, 223, 17, 103, 104, 61, 62, 447, 100, 43, 112, 80, 222, 109, 192, 220, 57, 63, 36, 102, 120, 113, 44, 84, 82, 895, 98, 256, 99, 221, 216, 446, 34, 207, 23
OFFSET
1,3
COMMENTS
Note the indexing: the domain starts from 1, while the range includes also zero.
FORMULA
a(1) = 0, a(2) = 1, and for n > 2, if A008683(n) <> 0 [when n is squarefree], a(n) = 2*a(A013928(n)), otherwise a(n) = 1 + 2*a(A285328(n)).
PROG
(Scheme, with memoization-macro definec)
(definec (A285111 n) (cond ((<= n 2) (- n 1)) ((not (zero? (A008683 n))) (* 2 (A285111 (A013928 n)))) (else (+ 1 (* 2 (A285111 (A285328 n)))))))
(Python)
from operator import mul
from sympy import primefactors
from sympy.ntheory.factor_ import core
from functools import reduce
def a007947(n): return 1 if n<2 else reduce(mul, primefactors(n))
def a285328(n):
if core(n) == n: return 1
k=n - 1
while k>0:
if a007947(k) == a007947(n): return k
else: k-=1
def a013928(n): return sum([1 for i in range(1, n) if core(i) == i])
def a(n):
if n<3: return n - 1
if core(n)==n: return 2*a(a013928(n))
else: return 1 + 2*a(a285328(n))
print([a(n) for n in range(1, 121)]) # Indranil Ghosh, Apr 17 2017
CROSSREFS
Inverse: A285112.
Similar or related permutations: A243343, A243345, A277695, A284571.
Sequence in context: A082315 A342266 A082320 * A253566 A333220 A176798
KEYWORD
nonn
AUTHOR
Antti Karttunen, Apr 17 2017
STATUS
approved