Write a JavaScript program to calculate factorial of n numbers

 


Code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Practical-13</title>
</head>

<body>
    <script>

        //Write a program to calculate factorial of n (Note: Use prompt box to get input from the user.)

        var num = prompt("Enter the Number");
        var fact = 1;
        for (let i = 1i <= numi++) {
            fact = fact * i;

        }
        alert("Factorial of the number is : " + fact);
    </script>
</body>

</html>

Output:




Comments

Popular posts from this blog

Write A Program To Print Hello World Using Lex

Create a Student registration form using following tags form,input,textarea,button,select,optio. The registration form must consist of following information: first name,Middle name,last name, gender(use radio button),address,phone no,email id,hobbies(use checkbox),city,state,country,collage name (use dropdown menu).