[seqfan] Re: Problem reproducing A019989, A019990, and A019991
Kevin Ryde
user42_kevin at yahoo.com.au
Mon Apr 22 02:03:04 CEST 2019
mlb at well.com (Marc LeBrun) writes:
>
> FWIW here's the claimed trisection as a single offset-0 sequence, with
> a(n) being 0, 1 or 2 when n is respectively in A019989, A019990 or
> A019991
>
> 0 1 0 1 1 0 0 1 0 1 2 1 1 1 0 0 0 2 0 1 0 1 1 0 0 1 0 1 2 1 2 2 1 1 1
> ...
I make this 2*n in balanced ternary, sum the non-zero digits with
every second such negated, starting from negate the most significant.
Total mod 3. Some GP code below for definiteness.
The number of non-zeros in balanced ternary 2*n is even, so if preferred
can start lowest non-zero not negated, second lowest non-zero negate, etc.
I got there from Brad Klee's draft 6-symbol morphism "bi-infinite" or
"start in the middle" meaning balanced ternary, then a slight leap to
the states implied by that morphism stepping towards or away from
target 0=accepting.
I wondered if there'd be a nice rule based on ternary n, instead of 2*n.
It's still matched by a state machine (so regular language), but seems
more compilcated.
\\ vector of balanced ternary digits of n, high to low
balanced_ternary(n) =
{
my(l=List([]));
while(n, listput(l,(n+1)%3-1); n=(n-l[#l])/3);
Vecrev(l);
}
\\ 0,1,2
\\ A019989 = n where 0
\\ A019990 = n where 1
\\ A019991 = n where 2
by_balanced(n) =
{
my(v=balanced_ternary(2*n),
s=-1, \\ sign to multiply each non-zero digit
total=0);
for(i=1,#v, \\ high to low
if(v[i], total += s*v[i]; s=-s));
total % 3;
}
vector(35,n,n--; by_balanced(n)) \\ n=0 to n=34
More information about the SeqFan
mailing list