Skip to content

Instantly share code, notes, and snippets.

@vithalreddy
Created November 13, 2019 06:23
Show Gist options
  • Save vithalreddy/27385735f2ca36a2dd54eb950b8c69d9 to your computer and use it in GitHub Desktop.
Save vithalreddy/27385735f2ca36a2dd54eb950b8c69d9 to your computer and use it in GitHub Desktop.
Taylor Series using Horner's Rule in Javascript
function ex(x, n, s = 1) {
if (n === 0) return s;
s = 1 + (x * s) / n;
return ex(x, n - 1, s);
}
console.log(ex(1, 10)); // 2.7182818011463845
console.log(ex(5, 10)); // 146.38060102513225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment