write a vb script to calculate factorial of a number?

Answer Posted / raja

Dim n,f
n=inputbox("enter a number")
f=1
If n<0 Then
msgbox "invalid number"
else if n=0 or n=1 then
msgbox "the factorial of given number is : "& f
else
For i=1 to n
f=f*i
Next
msgbox "the factorial of given number is : "&f
End If
end if

Is This Answer Correct ?    77 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 2 ways to pass a value to the function?

510


Which operator is used to concatenate the 2 values in the vbscript language?

554


Why is error handling required?

567


write a function to read the items from combobox of Flight reservation & save in excel (QTP)??

2391


If a calulator having 3 buttons (of any number)in 3 of them one is not working properly due to which answer is wrong always. write a script to find out which button is not working properly ?

1554






Set srchobj=Description.Create() srchobj("type").value="text" srchobj("name").value="q" srchobj("html tag").value="input" browser("micclass:=google").Page("micclass:=google").webedit (srchobj).Set "qtp" what's wrong in my code pls tell me ? the above code working fine and i got my result pass,now i am trying to run the program it shows general run time error why?pls help me i am in learning stage ?

1550


How will you convert a given number to long in vbscript?

488


What are class properties?

650


Which in-built function related to an array joins substrings into one string in the vbscript language?

512


what is used of Property........End Property loop ? how to write the script for it?

1684


What are the 2 ways in which a variable can be declared in the vbscript language?

564


Explain the arrays in vb script?

583


Explain about the extension .hta?

619


Hellow friends, I am learning QTP,but here problem is VB script. please guide me how to learn VB script w.r.t QTP and if you know any books tell me or if you have any materials or any use full material or any else w.r.t QTP please post me p.p.sekhar

1961


what is the object hyrarchy in QTP for a web based application

1881