Dizzy integer enumeration
SOGL V0.12, 8 6 bytes
I».»⌡±
Try it Here! or try the first couple numbers (changed a bit so it'd work)
0-indexed.
Explanation:
I increment the input
» floor divide by 2
. push the original input
» floor divide by 2
⌡ that many times
± negate
Or simpler:
(input + 1) // 2 negated input // 2 times
I » ± . » ⌡
Python 2, 26 24 bytes
lambda x:-~x/2/(1-(x&2))
Try it online!
JavaScript (ES6), 18 bytes
1-indexed.
n=>n/(++n&2||-2)|0
Demo
let f =
n=>n/(++n&2||-2)|0
for(n = 1; n < 20; n++) {
console.log(n + ' --> ' + f(n))
}