This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A257728 #23 Jan 12 2025 14:56:05 %S A257728 1,2,3,4,5,6,7,8,11,9,13,10,17,12,19,14,23,18,37,15,29,21,43,16,31,26, %T A257728 61,20,41,28,71,22,47,34,89,27,67,52,163,24,53,42,113,32,79,60,193,25, %U A257728 59,45,131,38,103,84,293,30,73,57,181,40,109,95,359,33,83,65,223,49,149,119,463,39,107,91,337,72,241,209,971,35,97,74,251,58 %N A257728 Permutation of natural numbers: a(1)=1; a(2n) = not_an_oddprime(1+a(n)), a(2n+1) = oddprime(a(n)). %C A257728 Here oddprime(n) = n-th odd prime = A065091(n) = A000040(n+1), not_an_oddprime(n) = n-th natural number which is not an odd prime = A065090(n). %C A257728 This sequence can be represented as a binary tree. Each left hand child is produced as A065090(1+n), and each right hand child as A065091(n), when a parent contains n >= 1: %C A257728 | %C A257728 ...................1................... %C A257728 2 3 %C A257728 4......../ \........5 6......../ \........7 %C A257728 / \ / \ / \ / \ %C A257728 / \ / \ / \ / \ %C A257728 / \ / \ / \ / \ %C A257728 8 11 9 13 10 17 12 19 %C A257728 14 23 18 37 15 29 21 43 16 31 26 61 20 41 28 71 %C A257728 etc. %C A257728 Because all odd primes are odd, it means that even terms can only occur in even positions (together with odd composites, A071904, for each one of which there is a separate infinite cycle), while terms in odd positions are all odd. %H A257728 Antti Karttunen, <a href="/A257728/b257728.txt">Table of n, a(n) for n = 1..4096</a> %H A257728 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A257728 a(1) = 1; a(2n) = A065090(1+a(n)), a(2n+1) = A065091(a(n)). %F A257728 As a composition of other permutations: %F A257728 a(n) = A257729(A246378(n)). %F A257728 a(n) = A257802(A257726(n)). %o A257728 (PARI) %o A257728 A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n }; \\ This function from _M. F. Hasler_ %o A257728 A257728(n) = if(n<3, n, if(!(n%2), A002808(A257728(n/2)-1), prime(1+A257728((n-1)/2)))); %o A257728 for(n=1, 4096, write("b257728.txt", n, " ", A257728(n))); %o A257728 (Scheme) %o A257728 ;; With memoizing definec-macro. %o A257728 (definec (A257728 n) (cond ((< n 2) n) ((even? n) (A065090 (+ 1 (A257728 (/ n 2))))) (else (A065091 (A257728 (/ (- n 1) 2)))))) %Y A257728 Inverse: A257727. %Y A257728 Cf. A002808, A065090, A065091, A071904. %Y A257728 Related or similar permutations: A246377, A246378, A257726, A257729, A257802. %Y A257728 Differs from A255004 for the first time at n=17, where a(17) = 23, while A255004(17) = 15. %K A257728 nonn %O A257728 1,2 %A A257728 _Antti Karttunen_, May 09 2015