Task - The title pretty much sums it up: raise an integer x to power x, where 0<x
.
Restrictions:
- Use of exponentiation,
exp()
,ln()
, and any other powers-related language built-ins, likepow()
,x^x
,x**x
is forbidden. - You can assume that the given integer fits the limits of the programming language of your choice.
Test cases:
Input | Output
---------------
2 | 4
3 | 27
5 | 3125
6 | 46656
10 | 10000000000
This is code-golf, so the shortest program in bytes wins.
0
and that the expected output be specified (0
or1
or either). Finally, having to handle negative integers would be a nice addition to the challenge. \$\endgroup\$1
for0^0
. However,Foundation
+ Swift returns 0 \$\endgroup\$0
and instead specified that0<x
in the lead-in. I also removed the restriction that code shouldn't throw errors; that should go without saying. Feel free to roll back if necessary. \$\endgroup\$