3. (A) Using JavaScript design, a web page that prints factorial/Fibonacci series/any
given series
Factorial Series:
Factorial Series:
<html>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Enter Num: <input id="num"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button onclick="fact()">Factorial</button><br><br> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| THE FACTORIAL OF NO. IS :<input id="ans"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function fact(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var i, no, fact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fact=1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| no=document.getElementById("num").value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(i=1; i<=no; i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fact= fact*i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("ans").value= fact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</html>
Fibonacci series:
|
3. (A) Using JavaScript design, a web page that prints factorial/Fibonacci series/any given series
Reviewed by admin
on
December 24, 2019
Rating:
No comments: