mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Merge 14e3f46229
into ca3d16dcce
This commit is contained in:
commit
a2eb60538f
@ -9,6 +9,11 @@
|
|||||||
* @return {number}
|
* @return {number}
|
||||||
*/
|
*/
|
||||||
export default function fastPowering(base, power) {
|
export default function fastPowering(base, power) {
|
||||||
|
if (power === 1) {
|
||||||
|
// Any number raised to the power of one is always that number
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
if (power === 0) {
|
if (power === 0) {
|
||||||
// Anything that is raised to the power of zero is 1.
|
// Anything that is raised to the power of zero is 1.
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user