sub x_power_n { my $x = shift; my $n = shift; my $result = $x; my $i = 1; while ($i < $n) { $result *= $x; $i++; } return $result; }