OFFSET
1,2
COMMENTS
In binary, the sequence begins 1, 10, 11, 111, 1110, 11100, 111000, 1110000, 11100000, 111000000, 1110000000, 11011111111, 110111111111, 1101111111110, 11011111111100, ...
Conjecture: The number of 1's in the binary representation of each term is weakly increasing, i.e., A000120(a(n)) >= A000120(a(n-1)).
Proved by Matthew Scroggs; see link. - Peter Kagey, Jun 19 2019
LINKS
Peter Kagey, Table of n, a(n) for n = 1..1000
Matthew Scroggs, Number of 1s in A308092
FORMULA
a(n) = c(n) - c(n-1) for n > 2, where c(n) is the concatenation of the first n bits of the sequence.
EXAMPLE
For n=5, 1 + 2 + 3 + 7 + 14 = 1_2 + 10_2 + 11_2 + 111_2 + 1110_2 = 11011_2, the first five bits of the sequence.
MATHEMATICA
a[1]=1; a[2]=2; a[n_]:=a[n]=FromDigits[Flatten[IntegerDigits[#, 2]&/@Table[a[k], {k, n-1}]][[;; n]], 2]-Total@Table[a[m], {m, n-1}]
Table[a[l], {l, 40}] (* Giorgos Kalogeropoulos, Mar 30 2021 *)
PROG
(Ruby)
def first_bits(n, seq); seq.map { |i| i.to_s(2) }.join[0...n].to_i(2) end
def next_term(n, seq); first_bits(n, seq) - first_bits(n-1, seq) end
def a308092_list(n)
(3..n).reduce([1, 2]) { |accum, i| accum << next_term(i, accum) }
end
(Python)
def aupton(terms):
alst, bstr = [1, 2], "110"
for n in range(3, terms+1):
an = int(bstr[:n], 2) - int(bstr[:n-1], 2)
alst, bstr = alst + [an], bstr + bin(an)[2:]
return alst
print(aupton(34)) # Michael S. Branicky, Mar 30 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Peter Kagey, May 12 2019
STATUS
approved