A057300 Binary counter with odd/even bit positions swapped; base-4 counter with 1's replaced by 2's and vice versa.
0, 2, 1, 3, 8, 10, 9, 11, 4, 6, 5, 7, 12, 14, 13, 15, 32, 34, 33, 35, 40, 42, 41, 43, 36, 38, 37, 39, 44, 46, 45, 47, 16, 18, 17, 19, 24, 26, 25, 27, 20, 22, 21, 23, 28, 30, 29, 31, 48, 50, 49, 51, 56, 58, 57, 59, 52, 54, 53, 55, 60, 62, 61, 63, 128, 130, 129, 131, 136, 138
Offset: 0
Examples
a(31) = a(4*7+3) = 4*a(7) + a(3) = 4*11 + 3 = 47.
Links
- Paul Tek, Table of n, a(n) for n = 0..16383
- H. Ardal, T. Brown, V. Jungic, and J. Sahasrabudhe, On Additive and Abelian Complexity in Infinite Words, INTEGERS: Elect. J. Combin. Number Theory, 12 (2012), A21.
- T. C. Brown and A. R. Freedman, Arithmetic progressions in lacunary sets, Rocky Mountain J. Math., 17 Number 3 (1987), 587-596. doi:10.1216/RMJ-1987-17-3-587
- T. Brown, V. Jungic, and A. Poelstra, On 3-term double arithmetic progressions, INTEGERS: Elect. J. Combin. Number Theory, 14 (2014), A43.
- A. R. Freedman, Sequences on sets of four numbers, INTEGERS: Elect. J. Combin. Number Theory, 16 (2016), A33.
- J. Grytczuk, Thue type problems for graphs, points and numbers, Discrete Math., 308 (2008), 4419-4429.
- L. Halbeisen and N. Hungerbuhler, An application of van der Waerden's theorem in additive number theory, INTEGERS: Elect. J. Combin. Number Theory, 0 (2000), A7.
- Peter Hegarty, Permutations avoiding arithmetic patterns, The Electronic Journal of Combinatorics, 11 (2004), #R39.
- V. Jungic and J. Sahasrabudhe, Permutations destroying arithmetic structure, The Electronic Journal of Combinatorics, Volume 22, Issue 2 (2015), Paper #P2.5.
- G. Pirillo and S. Varricchio, On uniformly repetitive semigroups, Semigroup Forum, 49 (1994), 125-129.
- A. F. Sidorenko, An infinite permutation without arithmetic progressions, Discrete Math., 69 (1988), 211.
- Ralf Stephan, Some divide-and-conquer sequences ...
- Ralf Stephan, Table of generating functions
- Index entries for sequences related to binary expansion of n
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
C
#include
uint32_t a(uint32_t n) { return ((n & 0x55555555) << 1) | ((n & 0xaaaaaaaa) >> 1); } /* Falk Hüffner, Jan 23 2022 */ -
Maple
a:= proc(n) option remember; `if`(n=0, 0, a(iquo(n, 4, 'r'))*4+[0, 2, 1, 3][r+1]) end: seq(a(n), n=0..69); # Alois P. Heinz, Jan 25 2022
-
Mathematica
Table[FromDigits[IntegerDigits[n,4]/.{1->2,2->1},4],{n,0,70}] (* Harvey P. Dale, Aug 24 2017 *)
-
PARI
A057300(n) = { my(t=1,s=0); while(n>0, if(1==(n%4),n++,if(2==(n%4),n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); }; \\ Antti Karttunen, Apr 14 2018
Formula
Conjecture: a(2*n) = -2*a(n) + 5*n, a(2*n+1) = -2*a(n) + 5*n + 2. - Ralf Stephan, Oct 11 2003
a(4n+k) = 4a(n) + a(k), 0 <= k <= 3. - Jon Perry, Oct 06 2012
From Peter Munn, Dec 10 2019: (Start)
a(a(n)) = n.
a(n OR k) = a(n) OR a(k), where OR is bitwise-or (A003986).
a(n XOR k) = a(n) XOR a(k), where XOR is bitwise exclusive-or (A003987).
a(n AND k) = a(n) AND a(k), where AND is bitwise-and (A004198).
a(n) = 5*n/4 - 3*A053985(2*n)/8. - Alan Michael Gómez Calderón, May 20 2025
Comments