login
A257725
Permutation of natural numbers: a(0) = 0, a(lucky(n)) = 1 + 2*a(n-1), a(unlucky(n)) = 2*a(n), where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505.
9
0, 1, 2, 3, 4, 6, 8, 5, 12, 7, 16, 10, 24, 9, 14, 13, 32, 20, 48, 18, 28, 17, 26, 64, 40, 11, 96, 36, 56, 34, 52, 25, 128, 15, 80, 22, 192, 33, 72, 112, 68, 104, 50, 21, 256, 30, 160, 44, 384, 49, 66, 19, 144, 224, 136, 208, 100, 42, 512, 60, 320, 88, 768, 29, 98, 132, 38, 27, 288, 65, 448, 272, 416, 41, 200, 97, 84, 1024, 120, 37
OFFSET
0,3
COMMENTS
In other words, after a(0) = 0, if n is the k-th lucky number [i.e., n = A000959(k)], a(n) = 1 + 2*a(k-1); otherwise, when n is the k-th unlucky number [i.e., n = A050505(k)], a(n) = 2*a(k).
Because all lucky numbers are odd, it means that odd numbers occur in odd positions only (together with some even numbers, for each one of which there is a separate infinite cycle), while the even positions contain only even numbers.
FORMULA
a(0) = 0; for n >= 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = 1+(2*a(A109497(n)-1)), otherwise a(n) = 2*a(n-A109497(n)). [Where A109497(n) gives the number of lucky numbers <= n.]
As a composition of other permutations. For all n >= 1:
a(n) = A246377(A257732(n)).
a(n) = A237427(A257734(n)).
PROG
(Scheme, with memoizing definec-macro)
(definec (A257725 n) (cond ((zero? n) n) ((= 1 (A145649 n)) (+ 1 (* 2 (A257725 (- (A109497 n) 1))))) (else (* 2 (A257725 (- n (A109497 n)))))))
CROSSREFS
Inverse: A257726.
Related or similar permutations: A237427, A246377, A257732, A257734.
Cf. also A257690 (another similar permutation, but with a slightly different definition, resulting the first differing term at n=13, where a(13) = 9, while A257690(13) = 11).
Cf. also A257735 - A257738.
Sequence in context: A225850 A038150 A182831 * A257690 A336322 A277519
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 06 2015
EXTENSIONS
Formula in name corrected by Antti Karttunen, Jan 10 2016
STATUS
approved