# [K (Kona)], <s>21</s> 20 bytes

    {1+*&~x>+\1.%1+!3^x}

[Try it online!][TIO-k6gfty1f]

[K (Kona)]: https://github.com/kevinlawler/kona
[TIO-k6gfty1f]: https://tio.run/##y9bNzs9L/P8/zaraUFtLra7CTjvGUE/VUFvROK6i9n@auqGeqYKRgrGCsZ6hiaGpgomCqYI5UMjQ4D8A "K (Kona) – Try It Online"

Inspired by [Jo King's APL solution](https://codegolf.stackexchange.com/a/199193/75681)

Switched from oK to Kona, as it has `power`