write a vb script to calculate factorial of a number?
Answer Posted / rik mondal
The answer submitted by "mudaseer" is absolutely wrong and
the answer by "raja" is partially correct(because he did not
wrote additional HTML and script tags,which is difficult to
understand for beginners). Guys don't you check the answer
before posting?
anyways here is the correct answer. This will work 100%.
Just copy it and paste in you editor then save and compile
by IE.
<html>
<script language="vbscript">
n=inputbox("Enter a number")
dim f
f=1
if n<0 then
Msgbox "Invalid number"
elseif n=0 or n=1 then
MsgBox "The factorial of given number "&n&" is :"&f
else
for i=n to 2 step -1
f=f*i
next
MsgBox "The factorial of given number "&n&" is :"&f
end if
</script>
</html>
| Is This Answer Correct ? | 41 Yes | 16 No |
Post New Answer View All Answers
Hello Guys, If any body looking for "worksoft certify tool training in bangalore", please contact me aimansaud@gmail.com
Explain the adodb.stream class?
Explain the tristate constants in vbscript?
How will you get a random number between 0 and 1 in vbscript?
What are subprocedures in vbscript?
How to write VB script for login module?
Which data type/types are supported by vbscript language and what are their specialties?
how to write validation function for date in vb script
How are arrays declared in the vbscript language?
Which in-built functions are used to convert the specified expression in the form of date and string in the vbscript language?
What are the naming conventions while declaring a variable in the vbscript language?
What is the use of the date function in the vbscript language?
What are class events?
How to access array data?
What is the use of the instr function?