login
A210882
a(1)=1, a(n)=a(n-1)-1 if a(n-1)-1 > 0 is not in the set {a(k)| 1<=k<n}, else a(n)=p, where p is the least prime number not yet in the sequence.
2
1, 2, 3, 5, 4, 7, 6, 11, 10, 9, 8, 13, 12, 17, 16, 15, 14, 19, 18, 23, 22, 21, 20, 29, 28, 27, 26, 25, 24, 31, 30, 37, 36, 35, 34, 33, 32, 41, 40, 39, 38, 43, 42, 47, 46, 45, 44, 53, 52, 51, 50, 49, 48, 59, 58, 57, 56, 55, 54, 61, 60, 67, 66, 65, 64, 63, 62, 71
OFFSET
1,2
COMMENTS
A reordering of the natural numbers.
The sequence is self-inverse in that a(a(n))=n.
If n is a prime, then a(n+1) is the next prime > n. Hence, the subsequence 2, a(2+1), a(a(2+1)+1), a(a(a(2+1)+1)+1), a(a(a(a(2+1)+1)+1)+1), ... generates the sequence of primes A000040.
LINKS
FORMULA
a(1)=1, a(n)=p (where p is the least prime number > a(k) for 1<=k<n) if the minimal natural number not yet in the sequence is greater than a(n-1), else a(n)=a(n-1)-1.
a(n)<>n for all n>3.
p(n+1)=a(p(n)+1), where p(n) is the n-th prime.
a(n+1)=p(m+2), if a(n)-1 is the m-th prime, else a(n+1)=a(n)-1, for n>2.
a(n)=p(m)+p(m-1)-n+1, where m is the least index such that p(m)>n-1 (valid for n>2).
EXAMPLE
a(4)=5, since 5 is the least prime > a(1), a(2), a(3), and the minimal number not yet in the sequence (=4) is greater than 3=a(3).
a(5)=4, since 4 is not in the set {1,2,3,5}={a(k)| 1<=k<n}.
7=p(4)=a(p(3)+1)=a(a(p(2)+1)+1)= a(a(a(p(1)+1)+1)+1)= a(a(a(2+1)+1)+1).
KEYWORD
nonn
AUTHOR
Hieronymus Fischer, Apr 30 2012
STATUS
approved