Generalizing a sequence. Consider a sequence of the form:
$x[n]=-1,-1...,1,1,...,-1,-1...,1,1... \quad n>0$
One can think of this as a square wave ($\pm1$) with a 50 % duty cycle (coming from EE).
For the simplest case of such a series i.e. $-1,+1,-1,+1,-1...$, a general equation is quite trivial ($x[n]=-1^n$).
Can we have e general equation for the other cases i.e. when there are multiple $-1$'s followed by $+1$'s ?
 A: If you want $m$ negatives ones, followed by $m$ positive ones, et cetera, then use
$$-(-1)^{\lfloor{n/m}\rfloor}$$
where $\lfloor{x}\rfloor$ is the floor function, and the sequence starts with $n=0$. Happy New Year!
A: How about $x(k)=(-1)^{\left\lceil\frac{k}{n}\right\rceil}, k=1,2,3\ldots$? This will produce the sequence with $n$ of $-1$'s, followed by $n$ of $1$'s, followed by $n$ of $-1$'s etc.
Note: $\lceil x\rceil$ is $\operatorname{ceil}(x)$ - the smallest integer $\ge x$.
A: Try this:
$$x(k)=-\frac{2}{\pi}\left[\arctan\left(\sin\frac{(2k-1)\pi}{2n}\right)+\arctan\left(\csc\frac{(2k-1)\pi}{2n}\right)\right]$$
for $k=1,2,3,\ldots$. Took me a bit of time to craft it, but it should work.
A: Here's a nifty trick.
The $n$th roots of unity  $\omega_n = e^{\frac{2\pi i j}{n}}$ can be used to filter out elements of sequences.
You probably have already used tricks like $b_n = \frac{a_n + a_n(-1)^n}{2}$ to get a sequence that gives you the value $a_n$ for multiples of $2$ and $0$ otherwise.
If you want this but for a $k$ cycle, simply use $\displaystyle c_n = \frac{\sum_{j=0}^{k-1}a_n \omega_k^n}{k}$ and you can mess with it more to make it more interesting.
You could combine this with the techniques given in the other answers to create any such sequences of $1$'s you like.  
