• + 0 comments

    JS

      function factorial(n){
            if(n < 0){
                return -1;
            }
            if(n == 0 || n == 1){
                return 1;
            }else{
                return n * factorial(n-1);
            }
        }
        let value = input.split(/[\n]/g);
        let x = parseFloat(value[0]);
        let y = parseFloat(value[1]);
        let ans = (Math.pow(x,y) * Math.exp(-x))/factorial(y);
        console.log(ans.toFixed(3));