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
How will you get the smallest subscript of an array in vbscript?
We have 1 web page with names column. I am giving the Service Providers1,2,3.... @ that time dynamically some no of names are displaying in the webpage and The Pop up windows are opening(No.of Pop Up windows=No.of Names). The names may be diffar for each and every Service Provders (Dynamically) How can we handle the Dynamic values?
What are subprocedures in vbscript?
How will you release the memory acquired by an array variable in vbscript?
How can constants be declared in the vbscript language?
Mention what is select case statement?
Please let me Know regarding any material regarding VB Scripting which should be easily understandable for Beginners.
How to capture a runtime error in vbscript?
Explain the operator precedence in vb script?
how to increasing the numbers in a given text box please write a vb script
What is the purpose of on error resume next statement?
Which constant is used for print and display functions and works as same as pressing enter key?
Out of the different type of operators, which are evaluated first and last in the vbscript language?
What methods are used to create text files and open text files in the vbscript language?
1.I want to establish connection with excel and also want to fetch the data using SQL queries. 2.the code should be written in such a way that in future if I want to migrate from excel to MS excess database , then there should be minimal changes.