Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/mcm.js Secret

Created April 20, 2021 04:30
Show Gist options
  • Save parzibyte/79facc26e516697feba67fbb8ff2b76d to your computer and use it in GitHub Desktop.
Save parzibyte/79facc26e516697feba67fbb8ff2b76d to your computer and use it in GitHub Desktop.
const maximoComunDivisor = (a, b) => {
// https://parzibyte.me/blog
let temporal; //Para no perder b
while (b !== 0) {
temporal = b;
b = a % b;
a = temporal;
}
return a;
};
const minimoComunMultiplo = (a, b) => {
// https://parzibyte.me/blog
return (a * b) / maximoComunDivisor(a, b);
};
// https://parzibyte.me/blog
const a = 72, b = 50;
const mcm = minimoComunMultiplo(a, b);
console.log(`Mínimo común múltiplo de ${a} y ${b} es ${mcm}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment