Does a function exist that maps the natural numbers to the natural numbers excluding multiples of 2 and 3 and starting at an arbitrary point

discrete mathematicsnumber theory

This question is a generalization of this other question. To recap, I was looking for a function that mapped the set of natural numbers to the set of natural numbers excluding multiples of 2 or 3 or both. So a function $f: x \mapsto y$ where $x = \{0, 1, 2, 3,…,m\}$ and $y=\{1,5,7,11,13,17,…,n\}$ for some arbitrary limit $m$. @A.J. gave a great solution

$y=\qquad 6\left \lceil \dfrac{x}{2} \right \rceil + (-1)^x$

(Erratum: the independent set $y$ should have been $y=\{5,7,11,13,…,n\}$ however since an answer was given for $y=\{1,5,…,n\}$ I didn't want to change the original and the difference is trivial.)

Now I'm wondering about a generalization that allows for the set $y$ to start at an arbitrary point (that is not a multiple of 2 nor 3). For example instead of $x=0$ mapping to $y=1$ it would instead map to $y=5$ and the formula would then be $y=6\left \lceil \dfrac{x+3}{2} \right \rceil + (-1)^{x+3}$ in other words translated 3 units. Or if we wanted $x=0$ to may to $y=41$ then it would be $y=6\left \lceil \dfrac{x+13}{2} \right \rceil + (-1)^{x+13}$. But I only know this because I precomputed the set starting at 1 and translated the number per the number of skipped members. If the number is bigger this would be non-trivial. For example, $101$ is not a multiple of 2 nor 3 so what function would start with $x=0$ mapping to $y=101$ and then continue by skipping multiples of 2 and 3 e.g. $103, 107, 109$.

Is there a generalization for a function that given the "starting point" $a$ that is not a multiple of 2 nor 3, and the parameter $x$, it maps $x=\{0,1,2,3,…,m\}$ to $y$ where each member of $y$ is $\ge$ $a$ and each subsequent term is the next non-multiple of 2 nor 3?

Best Answer

For a map from the natural numbers, consider the function $$f(n)=3n+a-3+D$$ where

$D=1$ if $n$ is even and $a \equiv 1 \bmod 6 $

$D=-1$ if $n$ is even and $a \equiv 5 \bmod 6 $

$D=0$ otherwise.

If $n$ is odd then $f(n)\equiv a \bmod 6$. If $n$ is even then $f(n)\equiv a-3+D \bmod 6$. Thus no $f(n)$ is divisible by $2$ or $3$.

Also, for any positive integer $n$, $f(n+1)-f(n)=3\pm 1$ and so the sequence $f(n)$ is monotonic increasing with differences of $2$ or $4$. Thus no non-multiple of $2$ and $3$ greater than $a=f(1)$ is omitted and $f$ is the required function.

(For a map from the non-negative integers replace $n$ by $n+1$ in the formulae.)

A continuous function of $n$

Although you are only interested in integer values of $n$ it is amusing to extend the function to all $n$ and also to give it as a definition without different cases.

$$f(n)=3n+a-3-\frac{1+\cos n\pi}{\sqrt3}\sin\frac{a+3}{3}\pi.$$