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 A257729 #20 Jan 12 2025 14:56:01 %S A257729 1,3,7,2,19,6,5,12,4,28,71,10,17,9,20,8,13,40,41,95,16,26,11,15,30,14, %T A257729 21,56,109,57,359,125,25,38,18,24,31,44,22,32,61,77,29,143,78,445,73, %U A257729 162,36,54,27,35,23,45,62,33,46,84,43,104,179,42,185,105,545,98,181,208,51,75,503,39,59,50,34,63,85,48,103,64,114,60,37 %N A257729 Permutation of natural numbers: a(1)=1; a(prime(n)) = oddprime(a(n)), a(composite(n)) = not_an_oddprime(1+a(n)). %C A257729 Here composite(n) = n-th composite = A002808(n), prime(n) = n-th prime = A000040(n), 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). %H A257729 Antti Karttunen, <a href="/A257729/b257729.txt">Table of n, a(n) for n = 1..10000</a> %H A257729 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A257729 a(1) = 1; if A010051(n) = 1 [i.e., if n is a prime], then a(n) = A065091(a(A000720(n))), otherwise a(n) = A065090(1+a(A065855(n))). %F A257729 As a composition of other permutations: %F A257729 a(n) = A257728(A246377(n)). %F A257729 a(n) = A257802(A257731(n)). %e A257729 As an initial value we have a(1) = 1. %e A257729 2 is the first prime (= A000040(1)), so we take the a(1)-th odd prime, A065091(1) = 3, thus a(2) = 3. %e A257729 3 is the second prime, thus we take a(2)-th odd prime, A065091(3) = 7, thus a(3) = 7. %e A257729 4 is the first composite, thus we take a(1)-th number larger than one which is not an odd prime, and that is A065090(1+1) = 2, thus a(4) = 2. %e A257729 5 is the third prime, thus we take a(3)-th odd prime, which is A065091(7) = 19, thus a(5) = 19. %o A257729 (PARI) %o A257729 A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n}; %o A257729 A257729(n) = { if(1==n,n,if(isprime(n),prime(1+A257729(primepi(n))),if(4==n,2,A002808(A257729(n-primepi(n)-1)-1))))}; %o A257729 for(n=1, 10000, write("b257729.txt", n, " ", A257729(n))); %o A257729 \\ After _M. F. Hasler_'s PARI-code for A236854. %o A257729 (Scheme) %o A257729 ;; With memoizing definec-macro. %o A257729 (definec (A257729 n) (cond ((<= n 1) n) ((= 1 (A010051 n)) (A065091 (A257729 (A000720 n)))) (else (A065090 (+ 1 (A257729 (A065855 n))))))) %o A257729 ;; Alternatively, by composing other permutations: %o A257729 (define (A257729 n) (A257728 (A246377 n))) %Y A257729 Inverse: A257730. %Y A257729 Cf. A000040, A002808, A000720, A010051, A065090, A065091, A065855. %Y A257729 Related or similar permutations: A257728, A246377, A257731, A257802, A236854. %K A257729 nonn %O A257729 1,2 %A A257729 _Antti Karttunen_, May 09 2015