[seqfan] Re: Problem reproducing A019989, A019990, and A019991

Kevin Ryde user42_kevin at yahoo.com.au
Sat Apr 27 04:14:47 CEST 2019


bradklee at gmail.com (Brad Klee) writes:
>
> Taking Mod[-A307672,3] gives this sequence
> Gosper calls "magicd" (see G4G link therein),

Ah, oops, beaut.  Could have that among the definitions.  Does an
"alternating balanced ternary" representation have a name?
Davis and Knuth flip every second bit of binary for "folded"
representation, though balanced ternary doesn't look much like folding.
And yet maybe "alternating" suggests every second digit by position,
instead of every second non-zero.

> otherwise I
> think we are stuck with needing six symbols.
> Does it factor well enough to produce the parity
> separate from the offset?  I don't know.

For non-interest, here's a picture of the ordinary ternary I tried,
which is 9 states.  Not very good except it can count in 3^k blocks.

 http://user42.tuxfamily.org/temporary/ternary-A019989.pdf  (about 38k)
 http://user42.tuxfamily.org/temporary/ternary-A019989.tex


\\ 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);
}
\\ Vector of alternating balanced ternary digits of n, high to low.
\\ Alternating means every second non-zero digit negated, starting most
\\ significant not negated (so sign of high digit = sign of original n).
alternating_balanced_ternary(n) =
{
  my(v=balanced_ternary(n), f=1);
  for(i=1,#v, if(v[i], v[i]*=f; f=-f));
  v;
}
\\ Gosper's d(n).
sumdigits_alternating_balanced_ternary(n) = \
  vecsum(alternating_balanced_ternary(n))

print("A019989  ", \
select(n->sumdigits_alternating_balanced_ternary(2*n)%3==0, [1..3^4], 1));

print("A019990  ", \
select(n->sumdigits_alternating_balanced_ternary(2*n)%3==2, [1..3^4], 1));

print("A019991  ", \
select(n->sumdigits_alternating_balanced_ternary(2*n)%3==1, [1..3^4], 1));

print("A307672  ", \
vector(20,n,n--; (-sumdigits_alternating_balanced_ternary(n))%3 + if(n%2,3)));



More information about the SeqFan mailing list