write a vb script to calculate factorial of a number?

Answers were Sorted based on User's Feedback



write a vb script to calculate factorial of a number?..

Answer / mudaseer

vf=1
vnum=inputbox("enter a no")
for i=2 to vnum
vf=vf*i
next
msgbox vf

Is This Answer Correct ?    98 Yes 25 No

write a vb script to calculate factorial of a number?..

Answer / 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

write a vb script to calculate factorial of a number?..

Answer / 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

write a vb script to calculate factorial of a number?..

Answer / arvind singh

a = InputBox("Enter a no to calculate factorial for")
Result = 1
Do While a > 0
Result = Result*(a)
a = a-1
Loop
MsgBox Result

Is This Answer Correct ?    8 Yes 4 No

write a vb script to calculate factorial of a number?..

Answer / mogal

n = 12345
f =1
for i =1 to len(n)
f = f* i
next
msgbox f

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More VB Script Interview Questions

Which operator can be used to check if two numbers are equal or not in vbscript?

0 Answers  


after medical test,when will be the police verification

0 Answers   IBM,


how to comvert 120 into one hunderd twenty rupees only and vice varsa

0 Answers  


Explain few date functions in vbscript?

0 Answers  


Mention what is the main difference between function and sub-procedure?

0 Answers  


Write a program using Java Script / VBscipt that checks if two matrices have identical values in all the elements

1 Answers   Ignou,


we executed QTP scripts in one browser(i.e IN)same scripts is working on another browsers or not (i.e mean netscap,m azol..like )

6 Answers   Accenture,


What are class properties?

0 Answers  


Why to add checkpoint in QTP What's the purpose of checkpoints & how to add it

2 Answers  


Hi everybady, i have faced few Qns in one of i attended interview, please help me out with these below Qns. 1. how to join values without using join function? 2. how to compare values without using String compare function? 3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome B A N G A L o R E 4. Input is "CapGemini" but uotput should be like this "inimeGpaC" 5. Input is 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Can someone let me know results of this Qns, please. Thanks.

2 Answers   CSS Corp,


I have an excel sheet with multiple ID's in a column. Now i need fetch those ID's in an application and check whether if it already exist in the DB. If not then i have to go with the process of inserting them in the DB. If it exists then i need to skip that ID and move to the next ID and check the same and proceed. How can i do that with for loop and if condition?

0 Answers  


how to automatically update the sql server2005 database records when insert in vb6?

0 Answers  


Categories