login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

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

%I #23 Jan 12 2016 00:38:41

%S 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,

%T 96,36,56,34,52,25,128,15,80,22,192,33,72,112,68,104,50,21,256,30,160,

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

%N 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.

%C 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).

%C 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.

%H Antti Karttunen, <a href="/A257725/b257725.txt">Table of n, a(n) for n = 0..10000</a>

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

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

%F As a composition of other permutations. For all n >= 1:

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

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

%o (Scheme, with memoizing definec-macro)

%o (definec (A257725 n) (cond ((zero? n) n) ((= 1 (A145649 n)) (+ 1 (* 2 (A257725 (- (A109497 n) 1))))) (else (* 2 (A257725 (- n (A109497 n)))))))

%Y Inverse: A257726.

%Y Cf. A005408, A005843, A000959, A050505, A109497, A145649.

%Y Related or similar permutations: A237427, A246377, A257732, A257734.

%Y 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).

%Y Cf. also A257735 - A257738.

%K nonn

%O 0,3

%A _Antti Karttunen_, May 06 2015

%E Formula in name corrected by _Antti Karttunen_, Jan 10 2016