To print the factorial of a number using HTML code, you would need to use JavaScript in conjunction with HTML. Here is an example code snippet that you can use:
<!DOCTYPE html>
<html>
<head>
<title>Factorial Calculator</title>
<script>
function factorial()
{
let num = document.getElementById("num").value;
let result = 1;
for (let i = num; i >= 1; i--)
{
result *= i;
}
document.getElementById("result").innerHTML = result;
}
</script>
</head>
<body>
<h1>Factorial Calculator</h1>
<p>Enter a number to calculate its factorial:</p>
<input type="number" id="num">
<button onclick="factorial()">Calculate</button>
<p>The factorial of the number is: <span id="result"></span></p>
</body>
</html>
Notice: This code creates an HTML form with an input field for the user to enter a number and a button to trigger the factorial() function. The function calculates the factorial of the input number using a for loop, and then sets the result to be displayed in a span element with the id "result".
Tags:
print factorial number