Please answer me this javascript question. Need answer to part (2)
Don't make irrelevant comments please.
Share
Please answer me this javascript question. Need answer to part (2)
Don't make irrelevant comments please.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
[tex]\texttt{\textsf{\large{\underline{The C{o}de}:}}}[/tex]
The problem is solved using JavaScript.
<!DOCTYPE html>
<html>
<head>
<title>
JavaScript.
</title>
</head>
<body>
<table id="tt" border=1>
<tr>
<td>S.No.</td>
<td>Number.</td>
<td>Factorial.</td>
</tr>
</table>
<style>
table{
border-collapse: collapse;
}
td{
padding: 12px;
}
</style>
<script>
function factorial(a){
if(a==1)
return 1;
return a*factorial(a-1);
}
var a=parseInt(prompt("Please enter first number: "));
var b=parseInt(prompt("Please enter second number: "));
var c=1;
for(var i=a;i<=b;i++,c++){
var r= document.getElementById("tt").insertRow(i-a+1);
var c1 = r.insertCell(0);
var c2 = r.insertCell(1);
var c3 = r.insertCell(2);
c1.innerHTML = c;
c2.innerHTML = i;
c3.innerHTML = factorial(i);
}
</script>
</body>
</html>
[tex]\texttt{\textsf{\large{\underline{Explanation}:}}}[/tex]
See attachment for output.