I can't find much on the internet about this, but apparently vectors of naturals are called hyperscalars. It's not hard to bijectively map naturals to 2D hyperscalars and with that to prove that any-dimensional hyperscalars are countable and thus bijectively mappable to naturals.


More specifically, I'm interested in mapping naturals to 2D hyperscalars, and to do so I've defined a hyperscalar sequence $a\_n$ such that:


* $a\_0 = (0, 0)$
* $a\_{n+1} = f(a\_n)$


where $f((a,b)) = (a+1, max(0,b-1))$ if $a+b$ is even, else $(max(0,a-1),b+1)$


If I'm asked the $n$-th term of the sequence I'd have to compute it recursively, but is there an "algebraic" (can't seem to think of a better term, sorry) formula that computes that specific term without necessarily computing the others?
Although a different, but related, question, is there an algebraic way to do the opposite (i.e. take a hyperscalar $v$ and return $n$ such as $a\_n = v$)?



Mapping naturals to pairs of naturals and viceversa
$$a\_n=\{Y\_n,X\_n\}$$


where $X\_n$ is sequence [A319572](https://oeis.org/A319572) and $Y\_n$ is sequence [A319573](https://oeis.org/A319573) in the OEIS database. These are the coordinates of the stripe enumeration of $N \times N$ where $N = \{0, 1, 2, \ldots\}$. A *"Stripe Enumeration"* function to produce these sequences is provided [here](https://oeis.org/A319571).


Here is some Mathematica code to test for this:



```
f[{a_, b_}] := (1/2)*(1 - (-1)^(a + b))*{Max[0, a - 1], 
b + 1} + (1/2)*(1 + (-1)^(a + b))*{a + 1, Max[0, b - 1]}

RecurrenceTable[{a[n + 1] == f[a[n]], a[0] == {0, 0}}, a, {n, 0, 30}]

```

The output for $a\_n$ is


 {{0, 0}, {1, 0}, {0, 1}, {0, 2}, {1, 1}, {2, 0}, {3, 0}, {2, 1}, {1, 
 2}, {0, 3}, {0, 4}, {1, 3}, {2, 2}, {3, 1}, {4, 0}, {5, 0}, {4, 
 1}, {3, 2}, {2, 3}, {1, 4}, {0, 5}, {0, 6}, {1, 5}, {2, 4}, {3, 
 3}, {4, 2}, {5, 1}, {6, 0}, {7, 0}, {6, 1}, {5, 2}}


Compare with


$$Y\_n=0, 1, 0, 0, 1, 2, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5$$
$$X\_n=0, 0, 1, 2, 1, 0, 0, 1, 2, 3, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2$$


