Introduction (may be ignored)
Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth challenge).
This challenge has a mild Easter theme (because it's Easter). I took my inspiration from this highly decorated (and in my personal opinion rather ugly) goose egg.
It reminded me of the Ulam spiral, where all positive integers are placed in a counter-clockwise spiral. This spiral has some interesting features related to prime numbers, but that's not relevant for this challenge.
We get to this challenge's permutation of positive integers if we take the numbers in the Ulam spiral and trace all integers in a clockwise turning spiral, starting at 1. This way, we get:
1, 6, 5, 4, 3, 2, 9, 8, 7, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, etc.
Given an integer input \$n\$, output \$a(n)\$ in integer format, where \$a(n)\$ is A090861.
Note: 1-based indexing is assumed here; you may use 0-based indexing, so \$a(0) = 1; a(1) = 6\$, etc. Please mention this in your answer if you choose to use this.
Input | Output --------------- 1 | 1 5 | 3 20 | 10 50 | 72 78 | 76 123 | 155 1234 | 1324 3000 | 2996 9999 | 9903 29890 | 29796
- Input and output are integers.
- Your program should at least support input in the range of 1 up to 32767).
- Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
- Default I/O rules apply.
- Default loopholes are forbidden.
- This is code-golf, so the shortest answers in bytes wins