A fun number sequence

A fun number sequence

The other day, while programming a small script, I encountered a fun number sequence I wanted to write about.

This sequence is created as follows:
We start with , the set of natural numbers. Then, we put the numbers of into the formula . The sequence we get is: n: 1 2 3 4 5 6 7 8 9 10 ... x: 1 2 4 8 16 32 64 128 256 512 ...

One thing one might be quick to notice is that this sequence doubles on every iteration. However, this sequence becomes more useful and interesting when put into binary. The binary sequence looks like: 1 10 100 1000 10000 100000 ...

The reason this sequence is useful becomes clear when we want to combine two numbers. Say we and to send the numbers 7 and 3 while only sending one number. In decimal numbers, we might add the two together and get 10, but then we cannot derive the original numbers any more. In this binary sequence however, we add 3 (100) and 7 (1000000) to get 1000100. From this, we can always derive the original numbers.

There are two more interesting things about this sequence in my opinion. First is when we attempt to reverse the sequence. Say we have x and want to get n, there are two formulae we can use: or

However, there is another method we can use that does not use a mathematical formula. If you paid close attention to the binary sequence before, you might have noticed that n is the number of digits of x in binary.

The second point of interest appears when we change the 2 in the formula. If we use the formula as y=3 and convert the answer into base-3 (trinary), we get the same sequence as y=2 in base-2 (binary). 1 10 100 1000 10000 100000 ... If we enter y=10, then we needn’t even do a conversion, as our usual numbers are already base-10 (decimal). Thus, we get the same sequence yet again.

I doubt this information will be of use to you, but I hope you may share in my appreciation of this sequence.