# [seqfan] Does the first part of this algorithm work only with the powers of 2?

Sat Jan 4 08:00:57 CET 2020

```Hi Everyone,
We start with a(1)=1, and continue with this definition: a(n) = number of even terms if a(n-1) is even; otherwise a(n) = a(n-1)+n.

This is the sequence we get:
1, 3, 6, 1, 6, 2, 3, 11, 20, 4, 5, 17, 30, 6, 7, 23, 40, 8, 9, 29, 50, 10, 11, 35, 60, 12, 13, 41, 70, 14,…

It doesn’t seem like a super exiting sequence, but when I generalized the definition, the algorithm "worked" only with the powers of 2. For the other numbers I checked, the first part of the definition became useless after few terms.

Starting with a(1) = 1, the generalized definition is:
a(n) = number of terms divisible by m if a(n-1) is divisible by m; otherwise a(n) = a(n-1)+n.

This is the sequence we get when m = 3.
1, 3, 1, 5, 10, 16, 23, 31, 40, 50, 61, 73, 86, 100, 115,…After a(2), there will be no multiples of 3, and we will keep using only the second part of the definition.
The same thing happened when m = 5, 6, 7, 9, 10, 11,…

However, if m is a power of 2, the multiples of m don’t seem to stop.

For example, this is the sequence we get when m = 8:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 1, 18, 36, 55, 75, 96, 2, 25, 49, 74, 100, 127, 155, 184, 3, 34, 66, 99, 133, 168, 4, 41, 79, 118, 158, 199, 241, 284, 328, 5, 51, 98, 146,…

Even when I changed a(1) to other natural numbers, I got similar results.

Can we say that the first part of the algorithm continues only with the powers of 2? And if so, why?
I put the sequences for m=2 to m=100 in an array. This is part of it. https://justpaste.it/7m5jm

Best,
Ali

```