OFFSET
1,3
COMMENTS
The first term must be omitted because it does not converge.
Start with the sequence of nonnegative integers [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...].
Swap all pairs specified by k=1, resulting in [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, ...], so the first term of the final sequence is 0 (No swaps for k>1 will affect this term).
Swap all pairs specified by k=2, resulting in [3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, ...], so the second term of the final sequence is 1 (No swaps for k>2 will affect this term).
Swap all pairs specified by k=3, resulting in [2, 0, 1, 3, 7, 4, 8, 6, 11, 5, 9, ...], so the third term of the final sequence is 3 (No swaps for k>3 will affect this term).
Continue for all values of k.
It appears that n is an odd prime number iff a(n+1)=n-1. If true, is there a formal analogy with the Sieve of Eratosthenes (by swapping instead of marking terms), or is this another type of sieve? - Jon Maiga, May 31 2021
LINKS
Jennifer Buckley, Table of n, a(n) for n = 1..10000
PROG
(Go)
func a(n int) int {
for k := n; k > 0; k-- {
if n%k == 0 {
if (n/k)%2 == 0 {
n = n + k
} else {
n = n - k
}
}
}
return n
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Jennifer Buckley, Sep 13 2019
STATUS
approved