Skip to content

Instantly share code, notes, and snippets.

@JaoodxD
Last active April 30, 2023 09:27
Show Gist options
  • Save JaoodxD/b1f3ce7cebb776d7ac2eab7f9dab48f7 to your computer and use it in GitHub Desktop.
Save JaoodxD/b1f3ce7cebb776d7ac2eab7f9dab48f7 to your computer and use it in GitHub Desktop.
Lagrange polynomial 'hello world!'
const greet = () => {
const L = (x) => -
( 1699 / 831600 * x ** 11) +
( 37339 / 302400 * x ** 10) -
( 589129 / 181440 * x ** 9) +
( 1965121 / 40320 * x ** 8) -
( 17402561 / 37800 * x ** 7) +
( 20479411 / 7200 * x ** 6) -
( 233153797 / 20160 * x ** 5) +
( 3667222847 / 120960 * x ** 4) -
(22023397139 / 453600 * x ** 3) +
( 2133337579 / 50400 * x ** 2) -
( 414933319 / 27720 * x ** 1) +
( 8 / 1 * x ** 0);
let n = 0;
let greetingString = '';
for (let i = 0; i <= 11; i++) {
let l = Math.round(L(i));
n += l;
greetingString += String.fromCharCode(96 + n);
}
return greetingString;
}
console.log(greet());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment