Write a JavaScript code to find factorial of N. (Use recursive function)

<html>
    <body>
        <script type = "text/javascript">
            var n = parseInt(window.prompt("Enter the Number:"));
            var result = fact(n);
            window.alert("Factorial of the given number " + result);
            function fact(n)
            {
                if(n == 0)
                    return 1;
                else
                    return (n*fact(n-1));
            }
        </script>
    </body>
</html>

6 comments:

  1. This is a good one but it appears only once per open.......

    ReplyDelete
  2. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. 
    Best Devops Training in pune
    Microsoft azure training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  3. Were a gaggle of volunteers as well as starting off a brand new gumption within a community. Your blog furnished us precious details to be effective on. You've got completed any amazing work!
    python Training institute in Chennai
    python Training institute in Bangalore
    python Training in Pune

    ReplyDelete
  4. I have found this blog very interesting.

    And it is very helpful and informative content.

    Keep posting.

    JavaScript Application Development in India.

    ReplyDelete