[seqfan] Re: Look left and say (binary version)

M. F. Hasler oeis at hasler.fr
Mon Nov 18 18:52:40 CET 2019


Jeremy, SeqFans,

if we just count the number of a(0)=1 that have occurred so far, then we
get:

print1(c=d=1); for(n=1,50, print1(", "c"="fromdigits(binary(c)));
c+=hammingweight(c))
1, 1=1, 2=10, 3=11, 5=101, 7=111, 10=1010, 12=1100, 14=1110, 17=10001,
19=10011, 22=10110, 25=11001, 28=11100, 31=11111, 36=100100, 38=100110,
41=101001, 44=101100, 47=101111, 52=110100, 55=110111, 60=111100,
64=1000000, 65=1000001, 67=1000011, 70=1000110, ...
which is
A010062 <https://oeis.org/A010062> a(0)=1; thereafter a(n+1) = a(n) +
number of 1's in binary representation of a(n).
[J: Thx for confirmation, just received.]

For counting '0's we would run into trouble after counting 1
preceding digit 0, which would eternally remain constant (and idem if at
some point we reached 3=11[2] or 7=111[2] etc.

We could also always count the total number of digits 0 *and* digit 1:
0, ("one 0":) 10[2] = 2[10], ("two 0s, one 1") => (2="10")+'0'+"1"+'1') =
10011[2] = 19[10], ("(total of) 4 '0's, 4 '1's) = 100 0 100 1 [2] = 137
[10],...
(not yet in OEIS)

Or, describe just the bits of the preceding term:
0,10, 1011, 10{3=111}1, ...
or rather:
0, (one '0',0 '1's:) 1001, (2=10[2] '0's, 2=10[2] '1's:) 100101, (3 '0's ,
3 '1's) 110111, , ...

As it happens, this hits a fixed point at the 8-th term:
{d(a,b=2, c1=hammingweight(a),
c0=logint(a+!a,2)+1-c1)=fromdigits(concat([binary(c0),0,if(c1,binary(c1)),1]),b)}
print1(a=0);for(n=1,50, printf(", %d[2] = %d[10]", d(a,10), a=d(a,2)))
0, 1001[2] = 9[10], 100101[2] = 37[10], 110111[2] = 55[10], 101011[2] =
43[10], 1001001[2] = 73[10], 1000111[2] = 71[10], 1101001[2] = 105[10],
1101001[2] = 105[10], ...

Also, the sequence d(n) = describe n in binary seems not in OEIS (neither
in base 2 nor base 10)
[d(n,10) | n<-[0..30]]
 = [1001, 11, 1011, 101, 10011, 10101, 10101, 111, 11011, 100101, 100101,
10111, 100101, 10111, 10111, 1001, 100011, 110101, 110101, 100111, 110101,
100111, 100111, 101001, 110101, 100111, 100111, 101001, 100111, 101001,
101001]
[d(n,2) | n<-[0..30]]
 = [9, 3, 11, 5, 19, 21, 21, 7, 27, 37, 37, 23, 37, 23, 23, 9, 35, 53, 53,
39, 53, 39, 39, 41, 53, 39, 39, 41, 39, 41, 41]
I will tentatively submit these.

- Maximilian

On Mon, Nov 18, 2019 at 5:53 AM Jeremy Gardiner via SeqFan <
seqfan at list.seqfan.eu> wrote:

> Dear seqfans,
>
> Inspired by the "Look left and say" sequence I experimented with a binary
> version of the sequence, shown below without separating commas.
>
> I noticed the intermediate values used to generate the sequences are
> interesting, these appear first.
>
> Starting at 0:
>
> >run "/sequences/leftbits.bas"
> 1,2,4,7,8,12,15,16,21,24,28,31,32,38,42,46,49,53,56,60,
>
> 0101001000111010000110001111010000010101011000011100011111010000001001100101
> 0100101110011000101101010111000011110000
>
> The intermediate values here give a known sequence A233271:
>
> a(0)=0; thereafter a(n+1) = a(n) + 1 + number of 0's in binary
> representation of a(n), counted with A080791.
>
> Starting at 1:
>
> >run "/sequences/leftbits.bas"
> 1,3,6,9,12,15,20,23,28,32,34,37,41,45,50,54,59,65,68,71,
>
> 1111111101100111100111111101001101111111001100000110001011001011101001110110
> 11110010111011011110111100000111000100110001111
>
> The intermediate values here give a new sequence:
>
> a(0)=0; thereafter a(n+1) = a(n) + 1 + number of 1's in binary
> representation of a(n).
>
> This does not appear to be in the OEIS.
>
> My program is below.
>
> Regards,
> Jeremy Gardiner
>
> rem Number of ones (or zeros) to my left
> rem Cf. 'look left and say' sequence
> rem Chipmunk BASIC v3.6.5(b3)
> rem written 17/11/19 by Jeremy C. Gardiner
> rem vars b$,s$,i,n,s
> rem Initial term 0 or 1
> b$="1"
> s$=b$
> for n=1 to 30
> rem count ones or zeros in string
> s=0
> for i=1 to len(s$)
> if mid$(s$,i,1)=b$ then s=s+1
> next i
> rem print intermediate values
> print str$(s)+",";
> rem append binary count plus b$ to string
> s$=s$+bin$(s)+b$
> next n
> print
> print s$
> end
>
>
>



More information about the SeqFan mailing list