Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = [
- '4',
- '3'
- ];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- // S = 1 + 1!/x + 2!/x2 + … + N!/xN.
- // n! = n * (n-1)!
- // n! = 1 if n = 0 or n = 1
- let N = Number(gets());
- let x = Number(gets());
- let factoriel = 1;
- let sum = 0;
- let sum2 = 0;
- for (let i = 1; i <= N; i++) {
- factoriel *= i;
- }
- console.log(factoriel);
- sum += 1 + 1 / x + 2 / Math.pow(x, 2) + factoriel / Math.pow(x, N);
- print(sum.toFixed(5));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement