I'm struggling to get a sequence of numbers $0$ and $1$ so that $1$ is repeating after a stable interval. For example:

$$\frac{(1-((-1)^{\lfloor\frac{n}{12}\rfloor} ((-1)^{\lfloor\frac{n}{11}\rfloor}))}{2}$$

will give:


But what I really need is to repeat digit $1$ after every $12$ steps and keep rest of the digits $0$:



I have tried with $mod$, $floor$, $ceiling$, $(-1)^n$ combinations, which I rather use instead of trigonometric functions or logical blocks, but haven't really made it.

  • $\begingroup$ See here. $\endgroup$ – QC_QAOA Sep 10 '18 at 4:51
  • $\begingroup$ @MarkokraM Just use a piecewise function... For example $\begin{cases}1&\text{if }12\mid n\\0&\text{otherwise}\end{cases}$ $\endgroup$ – user202729 Sep 10 '18 at 4:54
  • $\begingroup$ Is there any other way than using summation and trigonometry to do it? $\endgroup$ – MarkokraM Sep 10 '18 at 4:55
  • $\begingroup$ @user202729 I rather use plain arithmetics if possible. I added this restriction to my question. $\endgroup$ – MarkokraM Sep 10 '18 at 4:58
  • 1
    $\begingroup$ Although it's possible to do it, I don't understand why. This is not code-golf, and you probably want your formula to be clear rather than short. $\endgroup$ – user202729 Sep 10 '18 at 5:00

One way with floor and ceiling is

$$1-\left\lceil\frac{n-12\left\lfloor\frac{n}{12}\right\rfloor}{12}\right\rceil=\begin{cases}1&\text{if $n\equiv 0\pmod{12}$}\\0&\text{if $n\not\equiv 0\pmod{12}$}\end{cases}$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.