# [GolfScript], <s>25</s> 24 bytes {:i;0.{@@).2$?.i<}do@;@} [Try it online!][TIO-lo8wh6c0] [GolfScript]: http://www.golfscript.com/golfscript/ [TIO-lo8wh6c0]: https://tio.run/##S8/PSStOLsosKPlf97/aKtPaQK/awUFTz0jFXi/TpjYl38HaofZ/XYFCwX8TBRMDS3MA "GolfScript – Try It Online" Block (function) leaving the two values on top of the stack. Explanation: | Code | Stack (bottom to top) | | --- | --- | | `{…}` Block | `2 17` | | `:i;` Assign to `i` | `2` | | `0.` | `2 0 0` | | `{…}do` Run until result is 0… | Showing first pass over: | | `@@` Stack shift | `-1 2 0` | | `)` Increment | `-1 2 1` | | `:` Duplicate | `-1 2 1 1` | | `2$` Push third from stack | `-1 2 1 1 2` | | `?` Exponentiate | `-1 2 1 2` | | `:` Duplicate | `-1 2 1 2 2` | | `i<` Less than `i`? | `-1 2 1 2 0` | | (pop and either repeat or stop) | `-1 2 1 2` | At the end of the loop, the stack looks like `-1 1 4 9 16 2 5 25` so we do `@;@` to make the top of the stack be `25 16`. It took like twenty minutes of fiddling around to get the stack manipulation to work right.