Last active
February 7, 2016 12:45
-
-
Save iamayaz/50a82178bbcc0593d84f to your computer and use it in GitHub Desktop.
Custom pow() function in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function raiseToPower($base,$exponent) | |
{ | |
// multiply the base to itself exponent number of times | |
$result=1; | |
for($i=1;$i<=$exponent;$i++) | |
{ | |
$result = $result * $base; | |
} | |
return $result; | |
} | |
echo raiseToPower(3,3); | |
//Output 27 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment