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
Explain about scrrun.dll?
How can you create an object in vbscript?
How are arrays declared in the vbscript language?
What are the disadvantages of vbscript?
How to throw an error in vbscript?
Can someone please tell me what poor design in a relational database (not the layout or style) is and how it can be avoided? PLEASE...im desperate.
Out of the different type of operators, which are evaluated first and last in the vbscript language?
i wrote vbscripit code in notepad i got error i am in learning stage if u ps tell me what wrong in my code my error is "object required descriptive at line one run time error"and my code is "set usernameobj=Descriptive.Create() usernameobj( "name").value="Username" set passwordobj=Descriptive.Create() passwordobj("name").value="password" set signinobj=Descriptive.Create() signinobj("name").value="sigin" browser("gmail").page("gmail").WebEdit("usernameobj").set ("enter username") Browser("gmail").Page("gmail").WebEdit("passwordobj").Set secure.Crypt.Encrypt("enter password") browser("gmail").page("gmail").WebButton("siginobj").click
how to write validation function for date in vb script
What is vbscript?
what is event handling?
how to increasing the numbers in a given text box please write a vb script
How to pass argument by reference to a function in vbscript?
How will you get the natural logarithm of the given number in vbscript?
How will you get a subset of a array in vbscript?