| Conditions | 4 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function myPow(float $x, int $n): float |
||
| 10 | { |
||
| 11 | if ($n === 0) { |
||
| 12 | return 1; |
||
| 13 | } |
||
| 14 | |||
| 15 | if ($n < 0) { |
||
| 16 | [$x, $n] = [1 / $x, -$n]; |
||
| 17 | } |
||
| 18 | |||
| 19 | if ($n % 2 === 0) { |
||
| 20 | $ans = self::myPow($x * $x, $n / 2); |
||
| 21 | } else { |
||
| 22 | $ans = $x * self::myPow($x * $x, intdiv($n, 2)); |
||
| 23 | } |
||
| 24 | |||
| 25 | return $ans; |
||
| 26 | } |
||
| 58 |