OFFSET
1,1
COMMENTS
Start with the sequence of positive integers [1, 2, 3, 4, 5, 6, 7, 8, ...].
Swap all pairs specified by k=1, that is, do the swaps (2,1),(4,3),(6,5),(8,7),..., resulting in [2, 1, 4, 3, 6, 5, 8, 7, ...], so the first term of the final sequence is 2 (No swaps for k>1 will affect this term).
Swap all pairs specified by k=2, that is, do the swaps (4,2),(8,6),(12,10),(16,14),..., resulting in [2, 3, 4, 1, 6, 7, 8, 5, ...], so the second term of the final sequence is 3 (No swaps for k>2 will affect this term).
Swap all pairs specified by k=3, that is, do the swaps (6,3),(12,9),(18,15),(24,21),... .
Continue for all values of k.
The complementary sequence 1, 4, 6, 8, 9, 12, 14, 18, 20, 22, 24, 26, 28, ... lists the numbers that never appear. Is there an alternative characterization of these numbers?
Equivalently, is there a characterization of the numbers (2, 3, 5, 7, 10, 11, 13, 15, 16, 17, 19, 21, 23, ...) that do appear? - N. J. A. Sloane, Sep 13 2019
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
}
(SageMath)
def a(n):
for k in srange(n, 0, -1):
if k.divides(n):
n += k if is_odd(n//k) else -k
return n
print([a(n) for n in (1..67)]) # Peter Luschny, Sep 14 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Jennifer Buckley, Sep 13 2019
STATUS
approved