A345255 Carter and Reyes sequence for the game of countably infinitely many hats.
-1, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2, 3, 4, 1, 0, 0, 2, 1, 2, 5, 0, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2, 3, 4, 1, 0, 0, 2, 1, 2, 0, 6, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2
Offset: 0
Keywords
Links
- Numberphile, Hat Problems - Numberphile.
- Frederic Ruget, Towers of hats.
- Frederic Ruget, Hats Calculator.
- Frederic Ruget, Infinitely Many Hats.
- Stan Wagon, An Infinitely Puzzling Hat Problem.
Programs
-
JavaScript
function a(n) { if (n == 0) return -1; let offset = 0; while (true) { switch (n & 7) { case 1: return offset + 1; case 2: return 0; case 3: return 0; case 4: return offset + 2; case 5: return offset + 1; case 6: return offset + 2; } n = ((n >> 2) & (~1)) | (n & 1); offset += 2 } }
Formula
[a(n): 0 <= n < 7] = [-1, 1, 0, 0, 2, 1, 2]
For n >= 7:
if (n mod 8) in {1, 2, 3, 4, 5, 6}, then a(n) = a(n mod 8);
otherwise if n mod 8 = 0, then a(n) = a(2*floor(n/8)) + 2*[a(2*floor(n/8)) != 0],
otherwise a(n) = a(2*floor(n/8) + 1) + 2 * [a(2*floor(n/8) + 1) != 0].
Comments