1

Suppose I have the rule

$$k \text{ mod } 2$$

Then $$0,1,2,3,4,5,6,...$$ produces $$0,1,0,1,0,1,0,...$$

I want to create a function that would allow me to do a sequence like 2-2-3

So I would have

$$0,1,2,3,4,5,6,...$$

and this would yield

$$0,1,0,1,0,1,2,...$$

What's the most elegant way to do this?

I intend to do this with arbitrary integers, so instead of 2-2-3, I might have 2-4-7-8, etc. So a solution stated generally would be best.

  • 2
    Could you provide additional context? What do you mean by create an operator? – Michael Burr Jan 01 '21 at 22:03
  • 4
    I think "easiest" needs to be clarified here - what context do you plan to use this for? The answer of "how can I most clearly define this for a human" vs. "how can I most efficiently compute this on a computer" are certainly different - and maybe you mean something else (e.g. how can I encode this in a particular mathematical theory) – Milo Brandt Jan 01 '21 at 22:03
  • I tried to update the question based on feedback – Stan Shunpike Jan 02 '21 at 05:03

1 Answers1

2

Trivial answer for your first example: take a polynomial $P$ s.t.: $$P(0) = 0, P(1) = 1,..., P(6) = 2.$$ The function $$n\mapsto P(n\mod 7)$$ is a "changed modulo operator" for you?