OFFSET
1,2
LINKS
Dominic McCarty, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = n for n in A053738. Otherwise, a(n) = n+1 for even n and a(n) = n-1 for odd n. - Dominic McCarty, Mar 12 2025
EXAMPLE
a(1) = 1 steps over 1 comma to be met by the odd term 3;
a(2) = 3 steps over 3 commas to be met by the odd term 5;
a(3) = 2 steps over 2 commas to be met by the same odd term 5;
a(4) = 4 steps over 4 commas to be met by the odd term 9 (the odd term 5 is closer, but this is not the point);
a(5) = 5 steps over 5 commas to be met by the odd term 11 (again, the odd terms 7 and 9 are closer, but we don't care); etc.
PROG
(Python) def a(n): return n if len(bin(n))%2 else n-1 if n%2 else n+1 # Dominic McCarty, Mar 12 2025
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Mar 23 2020
STATUS
approved
