mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
fix: unnecessary steps
This commit is contained in:
parent
76617fa83a
commit
14e3f46229
@ -9,6 +9,11 @@
|
||||
* @return {number}
|
||||
*/
|
||||
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) {
|
||||
// Anything that is raised to the power of zero is 1.
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user