A333470 Lexicographically earliest sequence of distinct positive terms such that a(n) is the number of commas that a(n) has to step over (to the right) to be met by an odd term. This odd term might not be the closest odd term to a(n).
1, 3, 2, 4, 5, 6, 7, 9, 8, 11, 10, 13, 12, 15, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
Offset: 1
Examples
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.
Links
- Dominic McCarty, Table of n, a(n) for n = 1..10000
Programs
-
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
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