Last active
October 24, 2017 08:00
-
-
Save iuliaL/10a6f5d3351262653bcaefa317d84406 to your computer and use it in GitHub Desktop.
an implementation of positive or negative integer powers
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 pow(base,power) { | |
if ( power < 0 ) { | |
return ( 1 / pow( base, -(power)) ); | |
} else if (power == 0){ | |
return 1; | |
} else { | |
return base * pow(base, power - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment