Creating a repeating numerical pattern using a formula I'm trying to create a repeating numerical pattern using a formula.
Example of the numerical pattern -12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12 then it repeats
-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12
My thoughts where to use / alter the formula from https://oeis.org/ (-12 + 13*x)/(1 - x)^2 then add a Mod to limit the range between -12 and 12 somehow.

I tried the formula from https://oeis.org/ (-12 + 13*x)/(1 - x)^2 but when I create the formula in Libreoffice Calc (like excel).  I get something very different.

Any ideas how to create this repeating sequence -12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12 using a formula?
 A: You have found a generating function on OEIS, not just a function.   To find the $n$th term of the sequence it corresponds to, you need to find its $n$th derivative at $x=0$ and divide by $n!$. So if $G(x)=(-40 + 41x)/(1 - x)^2$ and you wanted $a_3$ then you would say $G'''(x)=  \frac{-222+246x}{(1-x)^5}$ and so $a_n=\frac{G'''(0)}{3!}=\frac{-222}{6}=-37$
Turning to your repeating sequence, you have $a_n=a_{n-25}$ so your generating function could have $1-x^{25}$ in the denominator to get the repeating pattern
You then have to choose a suitable numerator for the initial terms, such as $-12-11x-10x^2 -\cdots - x^{11}+x^{13}+2x^{14}+\cdots+12x^{24}$ so a generating function of $$\dfrac{-12-11x-10x^2 -\cdots - x^{11}+x^{13}+2x^{14}+\cdots+12x^{24}}{1-x^{25}}.$$
You could simplify that numerator, for example to $\frac{-12 +13x-13x^{25}+12x^{26}}{(1-x)^2}$,  giving a generating function of  $$\frac{-12 +13x-13x^{25}+12x^{26}}{(1-x)^2(1-x^{25})}.$$
Another approach giving the same answer is to say

*

*$\frac{x}{(1-x)^2}$ is the generating function for $0,1,2,3,4,\ldots$

*$\frac{1}{1-x}$ is the generating function for $1,1,1,1,1,\ldots$

*so $\frac{x}{(1-x)^2}-\frac{12}{1-x}$ is the generating function for $-12,-11,-10,\ldots$

*but we want the pattern to repeat every $25$ terms so need to divide this by ${1-x^{25}}$ to give $\frac{\frac{x}{(1-x)^2}-\frac{12}{1-x}}{1-x^{25}}$ and then tidy up


You can avoid generating functions.  Since your pattern repeats every $25$ terms, you can consider $n\pmod {25}$ as the remainder on division by $25$.  On its own that will give you a repeating pattern of $0,1,2,\ldots,24$ so you need to subtract $12$ to give you a repeating pattern of $-12,-11,-10,\ldots,12$, or in Excel something like
=MOD(A1,25)-12

