%I #8 May 10 2015 10:59:52
%S 1,2,3,4,6,8,5,12,7,16,10,24,11,14,15,32,20,48,22,28,9,30,64,40,23,96,
%T 44,56,18,60,13,128,31,80,46,192,19,88,112,36,120,26,47,256,62,160,92,
%U 384,21,38,27,176,224,72,240,52,94,512,124,320,184,768,29,42,76,54,63,352,39,448,144,480,95,104,43,188,1024,248,55
%N Permutation of natural numbers: a(1) = 1, a(lucky(n)) = (2*a(n))-1, a(unlucky(n)) = 2*n, where lucky(n) = n-th lucky number A000959, unlucky(n) = n-th unlucky number A050505.
%H Antti Karttunen, <a href="/A257690/b257690.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(1) = 1; for n > 1: if A145649(n) = 1 [i.e., if n is lucky], then a(n) = (2*a(A109497(n)))-1, otherwise a(n) = 2*a(n-A109497(n)). [Where A109497(n) gives the number of lucky numbers <= n.]
%o (Scheme, with memoizing definec-macro)
%o (definec (A257690 n) (cond ((= 1 n) n) ((= 1 (A145649 n)) (+ -1 (* 2 (A257690 (A109497 n))))) (else (* 2 (A257690 (- n (A109497 n)))))))
%Y Inverse permutation: A183089.
%Y Cf. A005408, A005843, A000959, A050505, A109497, A145649.
%Y Cf. also A257725 (similar permutation with a slightly different definition, resulting the first differing term at n=13, where a(13) = 11, while A257725(13) = 9).
%Y Cf. also A257735 - A257738.
%K nonn
%O 1,2
%A _Antti Karttunen_, May 09 2015
|