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)=?$$
$\endgroup$ 107 Answers
$\begingroup$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.
$\endgroup$ 1 $\begingroup$For example:
$$f(x) = (((4\cos(2x\pi/5) + 1)^2)/5 - 1)/4$$
or
$$f(x) = 1-(x^4 \mod 5)$$
See OEIS A079998 for more information.
Note: they are both $f(0)=1$. You get you sequence for $x \geq 1$.
$\endgroup$ $\begingroup$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... $$
$\endgroup$ $\begingroup$$$ 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) $$
$\endgroup$ $\begingroup$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.
$\endgroup$ $\begingroup$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 } $$
$\endgroup$ 2 $\begingroup$(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.
$\endgroup$ 1