OFFSET
1,2
COMMENTS
LINKS
FORMULA
EXAMPLE
As an initial value we have a(1) = 1.
2 is the first prime (= A000040(1)), so we take the a(1)-th odd prime, A065091(1) = 3, thus a(2) = 3.
3 is the second prime, thus we take a(2)-th odd prime, A065091(3) = 7, thus a(3) = 7.
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.
5 is the third prime, thus we take a(3)-th odd prime, which is A065091(7) = 19, thus a(5) = 19.
PROG
(PARI)
A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n};
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))))};
for(n=1, 10000, write("b257729.txt", n, " ", A257729(n)));
\\ After M. F. Hasler's PARI-code for A236854.
(Scheme, with memoizing definec-macro)
(definec (A257729 n) (cond ((<= n 1) n) ((= 1 (A010051 n)) (A065091 (A257729 (A000720 n)))) (else (A065090 (+ 1 (A257729 (A065855 n)))))))
;; Alternatively, by composing other permutations:
CROSSREFS
Inverse: A257730.
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 09 2015
STATUS
approved