# Formula for sequence $0, 0, 0, 0, 1, 0, 0, 0, 0, 1,\ldots$

There is a sequence with the values $0, 0, 0, 0, 1, 0, 0, 0, 0, 1, \ldots$ (basically there are always four 0s followed by a 1, then it repeats).

Is there a function for this sequence?

Here are two experiments for similar sequences:

For a sequence of $0, 1, 0, 1,\ldots$ it is: $$f(x)=\frac{(-1)^{x+1}+1}{2}=x\bmod 2$$ For a sequence of $0, 0, 1, 0, 0, 1,\ldots$ it is: $$f(x)=1-(((x+1) \bmod 3)-1)^2$$ For a sequence of $0, 0, 0, 1, 0, 0, 0, 1,\ldots$ it is: $$f(x)=?$$ For a sequence of $0, 0, 0, 0, 1, 0, 0, 0, 0, 1,\ldots$ it is: $$f(x)=?$$

• For any value of n, why not take $f(x) = n^{-1} \sum_{i= 1}^{n} \zeta_{n}^{x}$ where $\zeta_n$ is an $n^{th}$ root of unity?
Commented Sep 5, 2015 at 9:25
• @PadraigÓCatháin, the root of unity must be primitive for your formula to work, and you're missing an $i$ (the exponent should be $i x$) Commented Sep 5, 2015 at 9:31
• I should think you mean $x {\mod 2}$ rather than $x {\mod 1}$.
– JDH
Commented Sep 5, 2015 at 9:44
• See math.stackexchange.com/a/823883/21820 which is essentially the same question. Commented Sep 5, 2015 at 12:23
• en.wikipedia.org/wiki/… Commented Feb 12, 2016 at 17:30

I just want to point out a basic misconception in the question. You ask, "Is there a function for the sequence?" But the definition of a sequence is that it is a map (that is, a function) from N, the natural numbers, to some domain. So the answer is trivially yes.

What you meant to ask was probably, is there a way to express this function in terms of some given set $S$ of functions? But unless you say precisely what $S$ contains, one cannot answer.

P. S. A well-known theorem states that any purely periodic sequence of period n can be expressed as a linear combination of the n'th roots of unity. Maybe this is what you wanted.

• This is definitely the Right Answer, but I'm not sure the nth roots of unity are what OP actually wants. That brings complex numbers into what appears to be a basic algebra problem. Commented Sep 6, 2015 at 2:46

For example:

$$f(x) = (((4\cos(2x\pi/5) + 1)^2)/5 - 1)/4$$

or

$$f(x) = 1-(x^4 \mod 5)$$

Note: they are both $f(0)=1$. You get you sequence for $x \geq 1$.

For given n and x = 0, 1, 2...

$$\left \lfloor{{x \bmod n}\over{n-1}} \right \rfloor$$

Or:

$$\left \lfloor {{1} \over {99999}} \cdot 10^x \right \rfloor \bmod 10$$

$${1 \over 99999} = 0,(00001)$$

Fun fact: this is probably the simplest way to generate any repeatable sequence you need. Simply divide required sequence by a number consisting of equal number of nines, for instance: $${82742 \over 99999} = 0,827428274282742...$$

$$f(x) = \begin{cases} 0 & x \not\equiv 4 \pmod 5 \\ 1 & x \equiv 4 \pmod 5 \end{cases}$$

Or with the Iverson bracket,

$$f(x) = \left[x \equiv 4 \pmod 5\right]$$

However, one of the ones you were probably looking for is

$$f(x) = \frac{1}{5} \sum_{k=0}^4 \zeta^{k(x-4)}$$

where $\zeta$ is any primitive (complex) fifth root of unity; e.g. $\exp(2 \pi \mathbf{i} / 5)$, which can also be written as the principal value of the complex exponential $(-1)^{2/5}$. (there is a (messy) formula for this constant in radicals)

This formula is a special case of the Discrete Fourier Transform, which can be used to come up with a formula like this for any periodic sequence of complex numbers.

Naturally you could take the real part and write

$$f(x) = \frac{1}{5} \sum_{k=0}^4 \cos\left(\frac{2 \pi}{5} k (x-4) \right)$$

Take any periodic function $g$ of period $5$ that has at least one value that appears once only, let $g(4)$ WLOG. For example $g(n)=\sin\left(\frac{2\pi n}{5}\right)$.

Then the Lagrangian interpolant

$$f(n)=\frac{(g(n)-g(0))(g(n)-g(1))(g(n)-g(2))(g(n)-g(3))}{(g(4)-g(0))(g(4)-g(1))(g(4)-g(2))(g(4)-g(3))}$$ does the trick.

Generating functions is a way to express a sequence. For this example we would like a closed form of the function $$g(x) = a_0 + a_1x + a_2x^2 + a_3x^3 + a_4x^4 + a_5x^5 + a_6x^6 + a_7x^7 + a_8x^8 + a_9x^9 + \cdots$$ where $a_0=0,a_1=0,a_2=0,a_3=0,a_4=1,a_5=0,a_6=0,a_7=0,a_8=0,a_9=1,\dots$ We want thus a closed form for \eqalign{ g(x) &= x^4 + x^9 + x^{14} + x^{19} + \cdots \cr &= x^4 (1 + x^5 + x^{10} + x^{15} + \cdots) \cr &= {x^4 \over 1 - x^5} \cr }

• $g(0) = 0$, $g(1) = \text{undefined}$, $g(2) \approx -0.5$ ... this doesn't seem to be at all what we are looking for. And besides, $g(x)$ only works for $|x| < 1$ (otherwise the geometric series diverges) Commented Sep 5, 2015 at 17:44
• A generating function is a different way to express a sequence than the OP is looking for. He simply wants a function that eats an index and spits out the sequence element with that index. Commented Sep 5, 2015 at 19:08

(1+(-1)^z)/2 z=((n+1)(n+2)(n+3)/2) - 1

z = splitter

The formula for sequence {0,0,0,1,0,0,01,...} I call this as quadrivariate periodic zeroth dimensional sequence. Because i am still looking for formula for first dimension {1,1,1,1,2,2,2,2,3,3,3,3,...} and higher dimensions.

I am also looking for formula for {0,0,0,0,1,...} in terms of n without the use of modular math.

Bivariate periodic sequences {0,1,0,1,...} and Trivariate periodic sequences {0,0,1,0,0,1,...} were already constructed up to m dimension.

Univariate {0,0,0,0,...} sequences include the arithmetic sequences and the regular polygonal numbers and the integers raised to common power.