Created
August 24, 2024 18:23
-
-
Save jlewin/548db11755db0cc8f5dfa33cb8c33211 to your computer and use it in GitHub Desktop.
Quickly visualize a powers of a given base
This file contains hidden or 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 dumpPow(b, e) { | |
const steps = []; | |
console.log(`Raise ${b} to ${e}`); | |
for(let j = 0; j <= e; j++) { | |
const v = Math.pow(b, j); | |
const len = v.toString().length; | |
steps.push({ | |
step: j.toString().padStart(len + 2, " "), | |
v: " " + v | |
}); | |
} | |
console.log(steps.map(({step, v }) => step).join("")); | |
console.log(steps.map(({step, v }) => v).join("")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment