# Self-referential sequence that is sometimes powers of two

I've created an integer sequence where, after the first two elements, every element is calculated using the previous two. If the first two numbers are $$1$$ and $$3$$, the sequence goes as follows:

$$1, 3, 6, 8, 12, 15, 20, 22, 33, 36, 38, 57, 60, 62, 93, 96, 98, 105, 108$$

If the sequence starts with $$4$$ and $$6$$, however, the sequence is instead this:

$$4, 6, 9, 18, 20, 24, 27, 36, 38, 57, 60, 62, 93, 96, 98, 105, 108, 110, 115$$

If the sequence starts with $$1$$ and $$2$$, it goes:

$$1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144$$

The sequence is infinite, but there are certain starting numbers that are invalid, including when the first two numbers are equal. The sequence does not rely on the base and individual digits of the numbers, nor real-world things like seven-segment displays or letters.

I have three questions:

• What comes after $$115$$ in the second sequence, and why?
• If the sequence goes $$2, \_\_, \_\_, 16, 20$$, which numbers should fill in the blanks?
• What characterizes the first two elements of sequences generating powers of two?
• Is $2,3$ an invalid sequence? Commented Aug 23, 2023 at 18:32
• @DanDan0101 No, a sequence starting with $2, 3$ is valid. Commented Aug 23, 2023 at 18:47

The sequence is defined as:

Let $$a,b$$ be the two previous numbers. The next number is $$b$$ plus the smallest divisor of $$b$$ that isn't a divisor of $$a$$.

For example,

In the second sequence, say so far we have $$4,6,9,18,20$$. The last two numbers are $$a=18$$, $$b=20$$. The divisors of $$b$$ are $$1,2,4,5,10,20$$, of which $$4,5,10,20$$ are not divisors of $$a$$. We take the smallest one, $$4$$, and add it to $$b$$ to get the next number $$24$$.

This explains the note that we the sequence can't start with two of the same number because

the divisors of the two previous numbers are the same, so there's no divisor to add to continue the sequence. This would also happen is the second number were a divisor of the first.

To answer the questions:

• What comes after $$115$$ in the second sequence, and why?

The previous two elements are $$a=110$$ and $$b=115 = 5 \cdot 23$$. Since $$a$$ is divisible by $$5$$, we take $$23$$ and the next number is $$115 + 23 = 138$$.

• If the sequence goes $$2, \_\_, \_\_, 16, 20$$, which numbers should fill in the blanks?

It's $$7$$ making $$2, 7, 14, 16, 20$$. I tried some values until one worked.

• What characterizes the first two elements of sequences generating powers of two?

Any two consecutive powers of $$2$$. This causes the only divisor of $$b$$ but not $$a$$ to be $$b$$ itself, so the next value is $$b+b$$ continuing the powers of two. Two non-consecutive powers of $$2$$ won't do this.

• have you looked at puzzling.stackexchange.com/questions/122035/…
– qwr
Commented Aug 24, 2023 at 2:51
• This is the correct solution! Commented Aug 24, 2023 at 5:28
• I almost had this, but I was looking at prime factors instead of divisors. The first sequence works as "$b$ + the largest prime factor of $b$ that doesn't have a match in the prime factors of $a$", except for the transition from $8$ to $12$. Commented Aug 25, 2023 at 16:25
• @GentlePurpleRain That was my first thought too, but then the powers-of-2 convinced me to look at other divisors.
– xnor
Commented Aug 25, 2023 at 17:10