Integer function which takes every value infinitely often

A simple solution would be oscillating further and further away from origin, so f(0), f(1), f(2) ... will be:

0

-1 0 1

-2 -1 0 1 2

....

It's trivial and intuitive to see that each value is taken infinitely often.


Hint: you may use the following auxiliary map $g:\Bbb N\to\Bbb Z^2$.

enter image description here


For an explicit example:

$$f(n) = \begin{cases} i, & \text{if $n=p_i^a$ is a prime power} \\ -i, & \text{if $n=6p_i^a$ is six times a prime power}\\ 0, & \text{otherwise} \end{cases}$$

Here $p_i$ denotes the $i^{th}$ prime. Thus $f(27)=2=f(81)$, $f(6)=0=f(15)$, $f(12)=-1$ and so on.