Skip to content

Instantly share code, notes, and snippets.

@iuliaL
Last active October 24, 2017 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iuliaL/10a6f5d3351262653bcaefa317d84406 to your computer and use it in GitHub Desktop.
Save iuliaL/10a6f5d3351262653bcaefa317d84406 to your computer and use it in GitHub Desktop.
an implementation of positive or negative integer powers
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