# Series that don't have 3s

May 19, 2022

My 2019 attempt to make a series that has $0$ every third element and $n$ otherwise.

# Backstory

One of the last math topics we did in 9th grade (3º de la ESO) was series. My math teacher at the time (Marta) put up the challenge of coming up with a series that is just like $a_n = n$, except every third number it has to be $0$. I, of course, took the challenge. However, I couldn’t have expected how interesting this problem would end up being. Here I’ve compiled all the solutions I came up with back in 2019.

# Solutions

## 1. Sines

The function $\sin(n)$ is cyclic, so it makes sense to use it. We can adjust its phase to thirds by multiplying by $\frac{2\pi}{3}$:

However, I used $\tau$ back then and, while it certainly is a questionable choice, I will respect it today.

Thus, we have $\frac{\sqrt{3}}{2}$, $-\frac{\sqrt{3}}{2}$, $0$, …

We can normalize these values by multiplying by the reciprocals, $\frac{2}{\sqrt{3}} = \frac{2 \sqrt{3}}{3}$:

To get $1$, $-1$, $0$, …

And then we can square to get the correct signs:

So if we just multiply by the index, $n$, we have our series!

It’s interesting to note that this method wouldn’t work so nicely with periods other than 3. We were lucky that the magnitude of the reciprocal is the same for the two values that weren’t 0 (and we couldn’t just divide because we would have a problem with $\frac{0}{0}$).

Once I presented this solution to my teacher, she proposed to me a new challenge: sines (and any basic cyclic functions) are banned. What to do now?

## 2. Complex numbers

Actually, there is quite a simple workaround, but it’s kind of cheesy.

We know that complex numbers can be expressed as

If they have an argument of $1$. So, if we just take the imaginary part of $z$, we have a sine:

And this way we can substitute our previous result.

## 3. Check multiples

Let’s try to solve it cleanly, with the definition of multples.

A number $n$ is said to be a multiple of $p$ if:

So if we’re searching for positive multples of 3, we want the following condition:

The expression $n = 3k$ implies $3k - n = 0$. However, we don’t know value of $k$, so what could we do?

Well, we can just try all of the values of $k$. If (and only if) $n$ is actually a multiple of $3$ the previous difference will be $0$. If we take the product of all the differences, we will have a $0$ when $n$ is a multiple of $3$ and a different number otherwise.

Things are going to get messy, so let’s call this product $p_n$:

Now we have $0$ for multiples of 3 and some large product otherwise. Therefore, we have to find some way to leverage some special property that $0$ has.

One such property is that $0! = 1$. The only other number that has $1$ as its factorial is $1! = 1$, but if we just multiply $p_n$ by $2$ we will have our desired effect. We should also square it to avoid getting the gamma definition of the factorial when applied to negative numbers.

This way, not only every other number will not return $1$, *it will return an even number* (since every factorial after $2!$ has a factor of $2$). To summirize:

Now we can use a property of the parity of numbers. Namely, the fact that $(-1)^{2k} = 1$ and $(-1)^{2k + 1} = -1$. We can reduce to $0$ the odd case by adding $1$ and, since that will retun $2$ on the even case, we can divide by $2$. Thus we have a solution:

It’s easy to see that the product will never have to go past $n$ (or even $\frac{n}{3}$). I find the infinity more mathematically aesthetic, but I used $n$ on the implementation. Also, we have to reduce the product because we are taking a hilariously big factorial which will never be able to compute after a certain point. We can do this because we can prove that the parity is the only important aspect and will remain the same.

This solution very easy to modify for other periods (just replace the $3$!) and probably the cleanest.

## 4. Subtraction

Another approach is to cyclify our series, by substracting $3$ every third element.

Let’s try to subtract $3$ after the third element just once. We can separate values bigger and smaller than $3$ by subtracting… $3.5$. It’s quite ugly, but this way we have negative values between $1$ and $3$ and positive values afterwards.

We can extract the sign of a value $x$ if we do $\frac{|x|}{x}$, where $x \ne 0$, to avoid using less conventional notation.

We can do the same thing as for solution $3$ to convert these values into $0$ before and $1$ after:

So if subtract that to $n$ we would have $1$, $2$, $3$, $1$, $2$, $3$, $4$, …

We have the same series, but shifted over by $3$! This means we can do the same thing but for $n + 3$. Then we would have to do the same but for $n + 6$, then $n + 9$, etc…

So we have sum where the general term is $(n - 3k) - 3.5)$. As we only care for the sign and not the magnitude, we can de-uglify the expresion by multiplying by $2$. This way, the expresion is as follows:

The expression $s_n$ returns $1$, $2$, $3$, $1$, $2$, $3$, … indefinitely.

The easiest way to make it have $0$ every third element is to subtract $2$, offset it and do the same thing as with the sines. Back in the day for some reason I did it using factorials. The expression in question is the following:

There’s no justification for this last step other than “it just kinda works”.

## 5. Unbeknownst recursion

The previous solution was very recursive in nature. Could we just use recursion?

This is the last, and might be the most interesting. Looking back, I’m very surprised, since I hadn’t heard of recursion back then and I was kinda redescovering it myself.

Let’s take

Which is useful, because:

As before, this is the start of a counter that goes $1$, $2$, $3$, $1$, $2$, $3$, $4$, $5$, … So this counter works until $n = 6$.

One way to extend it is to “change” the $n$. More precisely, if we input numbers between $1$ and $6$ to $c_n$, then it’s going to work. The thing is that $c_n$ provides numbers between $1$ and $6$ until $n = 9$!

Remember that $c_n$ was defined as:

So $c_{c_n}$ is:

We can then input $c_{c_n}$ into $c_n$ to get it to work until $n = 12$:

And now the recursive nature is becoming apparent. Let’s call the recursive counter, $r_n$:

There is still one small problem. This recursion, as it stands, is infinte; any implementation would stack overflow. The easy solution is to define something like $r_0 = 0$. However, we can just prove it!

### Proof

First, observe that $\frac{ |2r_n - 7| }{2r_n - 7}$ is always either $1$ or $-1$. This means that $\frac{ |2r_n - 7| }{2r_n - 7} + 1$ is always $0$ or $2$, which in turn implies that $-\frac{3}{2}\left(\frac{ |2r_n - 7| }{2r_n - 7} + 1 \right)$ is always $0$ or $3$.

Using this, we can deduce that $\forall n (r_n \le n)$, since $r_n = n - 0$ or $r_n = n - 3$ and both satisy this condition.

Now, according to the definition of $r_n$, the value of $r_0$ is the following:

We know that $r_0$ can be, at most, $0$. However, any value less than $3$ will evaluate to $0$ in $\frac{3}{2}\left(\frac{ |2r_0 - 7| }{2r_0 - 7} + 1 \right)$. This means that $r_0 = 0 - 0 = 0$

QED.

So, finally, we can make the last series using the counter, and the same approach used in solution 4:

*Isn’t it beautiful?*

# Epilogue

This is the technical part of this project, but in 2020 I also made a video (in spanish) of my journey to get to the solutions. Finally, I’ve implemented this in a Pluto notebook written in Julia.