A109812 a(1)=1; thereafter a(n) = smallest positive integer not among the earlier terms of the sequence such that a(n) and a(n-1) have no common 1-bits in their binary representations.
1, 2, 4, 3, 8, 5, 10, 16, 6, 9, 18, 12, 17, 14, 32, 7, 24, 33, 20, 11, 36, 19, 40, 21, 34, 13, 48, 15, 64, 22, 41, 66, 25, 38, 65, 26, 37, 72, 23, 96, 27, 68, 35, 28, 67, 44, 80, 39, 88, 128, 29, 98, 129, 30, 97, 130, 45, 82, 132, 42, 69, 50, 73, 52, 74, 49, 70, 56, 71, 136, 51
Offset: 1
Examples
a(6) = 5, which is 101 in binary. Of the terms not among (1,2,4,3,8,5), the earlier terms of the sequence, 10 (decimal) = 1010 (binary) is the smallest positive integer with no common 1-bits with the binary representation of 5. Of the other positive integers not occurring earlier in the sequence (6 = 110 binary, 7 = 111 binary, 9 = 1001 binary), each has at least one 1-bit in common with 5 = 101 in binary. So a(7) = 10. To illustrate the formulas (3) & (4): The powers of two a(3) = 4, a(5) = 8, a(8) = 16, and a(15) = 32 are immediately followed by 3, 5, 6 and 7, respectively, which are the smallest numbers that did not occur earlier. - _M. F. Hasler_, Apr 03 2022
Links
- Paul Tek, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Log-log scatterplot of a(n), n = 1..2^20, showing "lakes" as a triangular void in each rank interval, and "breaks" (breche) that may or may not recur in the same location in each rank interval.
- Michael De Vlieger, Scatterplot of a(n), n = 1..2^20, with 1:1 aspect ratio.
- Michael De Vlieger, Scatterplot of a(n), n = 1..2^16, plotting even-indexed terms in red and odd in blue.
- Michael De Vlieger, Bitmap of a(n), n = 1..2^10, expanding terms vertically with least significant bit at bottom, showing 1's in black and 0's in white. 12X vertical exaggeration.
- Michael De Vlieger, Bitmap of a(n), n = 1..2^14, expanding terms horizontally with least significant bit at right, showing 1's in black and 0's in white. 256X horizontal exaggeration (4096 X 16384 image size).
- Michael De Vlieger, Log-log scatterplot of a(n), n = 2^15..2^16-1, even-indexed terms in red, odd in blue, superimposed upon 2*a([n/2]), shown in large amber points, so as to explore "fractal" quality of the sequence.
- Thomas Scheuerle, Graph of A109812 for n = 0..10^7
- Rémy Sigrist, The two bisections of this sequence are shown in red and blue. The arrows indicate places where the two bisections appear as parallel stripes (these are examples of brèches).
- Rémy Sigrist, The two bisections shown next to each other, alongside binary plots of the a(n)
- N. J. A. Sloane, Right-justified table of n, a(n) in binary, for n = 1..20000 [Copied from A352575]
- N. J. A. Sloane, Right-justified table of n, a(n) in binary for n = 1..10^6 [gzipped file, copied from A352575] [This file was corrupted, but today I replaced it with a corrected version. - _N. J. A. Sloane_, Apr 11 2022]
- N. J. A. Sloane, The brèche between n = 59 and n = 70
- N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences: An illustrated guide with many unsolved problems, Guest Lecture given in Doron Zeilberger's Experimental Mathematics Math640 Class, Rutgers University, Spring Semester, Apr 28 2022: Slides; Slides (an alternative source).
- Walter Trump, Log-log plot of first 22 blocks of powers of 2 [The logs are to base 2; the red lines are at powers of 2; for small n the points have been enlarged to make them visible; the x-axis shows values of n from 2^0 to 2^22]
- Walter Trump, Log-log plot of points a(n) for n from 2^19 to 2^25 [The logs are to base 2; the red lines are at powers of 2; the x-axis shows values of n from 2^19 to 2^25; the y-axis goes from 2^15 to 2^23]
- Walter Trump, Log-log plot of points a(n)/6 for n from 2^18 to 2^19
- Walter Trump, Log-log plot of points a(n)/6 for n from 2^19 to 2^20
- Walter Trump, Log-log plot of points a(n)/6 for n from 2^20 to 2^21
- Chai Wah Wu, Table of n, a(n) for n = 1..10^6
- Index entries for sequences that are permutations of the natural numbers
- Index entries for sequences related to binary expansion of n
Crossrefs
Cf. A115510, A113232, A113233, A113234, A340016, A352205, A352206, A352336, A352359, A352917-A352923, A353714.
For positions of powers of 2 see A305370.
Partial sums: A352781.
The graphs of A109812, A252867, A305369, A305372 (bisection) all have roughly the same, mysterious, fractal-like structure. - N. J. A. Sloane, Jun 03 2018
Programs
-
Haskell
import Data.Bits ((.&.)); import Data.List (delete) a109812 n = a109812_list !! (n-1) a109812_list = f 0 [1..] :: [Int] where f v ws = g ws where g (x:xs) = if v .&. x == 0 then x : f x (delete x ws) else g xs -- Reinhard Zumkeller, Sep 15 2014
-
Maple
read(transforms) : # ANDnos def'd here A109812 := proc(n) option remember; local c,i,known ; if n = 1 then 1; else for c from 1 do known := false ; for i from 1 to n-1 do if procname(i) = c then known := true; break ; end if; end do: if not known and ANDnos(c,procname(n-1)) =0 then return c; end if; end do: end if; end proc: seq(A109812(n),n=1..200) ; # R. J. Mathar, Mar 29 2022
-
Mathematica
nn = 71; c[] = 0; a[1] = c[1] = 1; u = 2; Do[If[a[i - 1] == u, While[c[u] > 0, u++]]; k = u; While[Nand[c[k] == 0, BitAnd[a[i - 1], k] == 0], k++]; Set[{a[i], c[k]}, {k, i}], {i, 2, nn}]; Array[a, nn] (* _Michael De Vlieger, Apr 05 2022 *)
-
PARI
A109812_vec(n=100, a=0, U=[a])={vector(n, i, my(k=U[1]); while(bitand(a, k++) || setsearch(U, k), ); if(k>U[1]+1, U=setunion(U, [k]), U[1]++); a=k)} \\ M. F. Hasler, Apr 03 2022; corrected Apr 07 2022
-
Python
A109812_list, l1, s, b = [1], 1, 2, set() for _ in range(10**6): i = s while True: if not (i in b or i & l1): A109812_list.append(i) l1 = i b.add(i) while s in b: b.remove(s) s += 1 break i += 1 # Chai Wah Wu, Jun 04 2018
Formula
It would be nice to have a formula or recurrence. - N. J. A. Sloane, Jun 02 2018
From M. F. Hasler, Apr 03 2022: (Start)
(1) If a(n) = 2^k and a(m) > 2^k then m > n: No term larger than 2^k can occur earlier than 2^k.
(2) For all k >= 0, a(n) = 2^k for some n <= 2^k: Any power of two will occur, not later than immediately after all smaller numbers.
(3) If a(n) = 2^k, and S(k) = {x < 2^k | x <> a(j) for all j < n} is not empty (which seems to be the case for all k > 1), then a(n+1) = min S(k): The smallest number less than a power of two that does not occur before it must occur immediately after it.
(4) If a(n) = 2^k with n < 2^k (probably true for all k > 1), then a(n+1) = min {x | x <> a(j) for all j <= n}. (End)
Extensions
More terms from John W. Layman, Aug 18 2005
Edited by N. J. A. Sloane, Jun 02 2018
Comments