# [seqfan] Re: Formulas for two sequences, A060574 and A067498 ?

M. F. Hasler oeis at hasler.fr
Tue Mar 29 01:35:01 CEST 2022

```Yes, for the tower of Hanoi there is a very simple algorithm that easily
translates to a formula :
on the first, third, fifth,... move, move the smallest disc to the next peg,
so the smallest disc is on peg (ceil(n/2) mod 3) after the n-th move,
which yields departure and arrival peg number for any of these moves.
On the 2nd, 4th, 6th... move, make the only possible move with a disc other
than the smallest one.
You can check that for moves numbered
A108269 <https://oeis.org/A108269> Numbers of the form (2*m - 1)*4^k where
m >= 1, k >= 1.this corresponds to the move (a -> a+1 (mod 3)) where a =
floor(n/2+1) mod 3 is the peg just "after" the one on which you just put
the smallest disc,
for the other even moves,  with numbers A036554
<https://oeis.org/A036554> (binary
representation ends in an odd number of zeros),
it's the "reverse" move: (a+1 (mod 3) -> a).

For the "number of reflections" sequence, i don't understand the given
definition, i will have a look at the sequence.

- Maximilian

*(PARI/GP) <http://pari.math.u-bordeaux.fr/gp.html>*
*Hanoi(n,p=[[]|n<-[1..3]])={p[1]=[1..n]; vector(2^n-1, n,** my(m = if(
bittest(n,0), [n\2%3, (n\2+1)%3]*
*, my(a = (n\2+1)%3, b = (a+1)%3); if(** !p[b+1] ||
(#p[a+1]&&p[a+1][1]<p[b+1][1])**,* *[a,b], **[b,a])/*if*/*
*)/*if*/ )/*my*/;** p[m[2]+1] = concat( p[m[1]+1][1],
p[m[2]+1]); p[m[1]+1] = p[m[1]+1] [^1]; m**)}*

On Mon, Mar 28, 2022, 08:06 Antti Karttunen <antti.karttunen at gmail.com>
wrote:

> Cheers,
>
> Does anybody know formulas for these two sequences?
>
> https://oeis.org/A060574
> Tower of Hanoi: using the optimal way to move an even number of disks
> from peg 0 to peg 2 or an odd number from peg 0 to peg 1, a(n) is the
> smallest disk on peg 1 after n moves (or 0 if there are no disks on
> peg 1).
>
> https://oeis.org/A067498
> Maximum number of reflections for a ray of light which reflects at n
> points (reflecting more than once at most or all points).
>
> These recently appeared among the newly mined LODA-programs (see
> https://github.com/loda-lang/ ), but at least for the latter there are
> so few terms present that it is highly likely a case of strong law of
> small numbers.
>
>
> Best regards,
>
> Antti
>
> --
> Seqfan Mailing list - http://list.seqfan.eu/
>

```