# JavaScript (ES6), 26 bytes Returns the \$n\$-th term of the sequence. Relies on arithmetic underflow to stop the recursion. <!-- language-all: lang-javascript --> f=n=>n?(-n%4/3|1)*f(n/2):1 [Try it online!][TIO-lpb0cbt3] [JavaScript (Node.js)]: https://nodejs.org [TIO-lpb0cbt3]: https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zTbP1i7PXkM3T9VE37jGUFMrTSNP30jTyvB/Wn6RRk5qiUKegq2CgTWQslEwAtHa2poK1VwKCsn5ecX5Oal6OfnpGgmJGirVebWaQKUq1UATNGsTNK25av8DAA "JavaScript (Node.js) – Try It Online" ### Commented f = n => // f is a recursive function taking the input n n ? // if n is not zero: ( // -n % 4 // the sign of n % m is the sign of n in JS, // so this gives 0, -1, -2, -3 // or -ε if n is not an integer anymore / 3 // dividing by 3 gives -1 if n % 4 == 3, // or a value in ]-1, 0] otherwise | 1 // a bitwise OR with 1 gives either 1 or -1 ) // * // we multiply by the result of ... f(n / 2) // ... a recursive call with n / 2 // once we have n < 1, the final result is not // changed anymore; and once n is small enough, // n / 2 will eventually be evaluated to 0 : // else: 1 // stop the recursion