How to calculate the power of a given number using recursion in PHP | PHP programs
Jan 27, 2022
PHP,
2725 Views
How to calculate the power of a given number using recursion in PHP | PHP programs
How to calculate the power of a given number using recursion in PHP | PHP programs
We will calculate the power of the specified given number using recursion.
<?php
//PHP program to calculate the power of a number
//using recursion.
function Power($num, $p)
{
if ($p == 0) return 1;
return $num * Power($num, $p - 1);
}
$result = Power(6, 3);
echo "Result is: " . $result;
?>


