Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - //"Calculate 1 + 1!/X + 2!/X^2 + … + N!/X^N");
 - let input =['3','2'];
 - let print = this.print || console.log;
 - let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
 - let n = Number(gets());
 - let x = Number(gets());
 - let result = 1;
 - let ifac = 1;
 - for (let i = 1; i <= n; i++)
 - {
 - ifac = 1; //This line is very important
 - for (let j = i; j >= 1; j--)
 - {
 - ifac *= j;
 - }
 - result += ifac / Math.pow(x, i);
 - }
 - print(result.toFixed(5));
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment