Skip to content

Instantly share code, notes, and snippets.

@jlewin
Created August 24, 2024 18:23
Show Gist options
  • Save jlewin/548db11755db0cc8f5dfa33cb8c33211 to your computer and use it in GitHub Desktop.
Save jlewin/548db11755db0cc8f5dfa33cb8c33211 to your computer and use it in GitHub Desktop.
Quickly visualize a powers of a given base
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