Skip to content

Instantly share code, notes, and snippets.

@siberex
Last active December 17, 2023 02:32
Show Gist options
  • Save siberex/cc4b805cdd6f64d43532ac8f88cb190f to your computer and use it in GitHub Desktop.
Save siberex/cc4b805cdd6f64d43532ac8f88cb190f to your computer and use it in GitHub Desktop.
Single-digit multiplication is just a mapping of a set of 55 (distinct) values to a set of 37 (distinct) values
const multipliers = new Map();
const multiplications = new Set();
for (let i = 0; i < 10; i++) {
for (let j = i; j < 10; j++) {
const res = i * j;
multiplications.add(res);
multipliers.set(
i.toString() + j.toString(),
res,
);
const logRes = Math.round(
Math.pow(10, Math.log10(i) + Math.log10(j))
);
console.assert(res === logRes);
}
}
@siberex
Copy link
Author

siberex commented Dec 17, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment