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


Please Help Members By Posting Answers For Below Questions

can anyone tell me the procedure of interview held in applabs

1755


Mention what is vbscript procedures?

543


What is the difference between for loop and while loop?

556


Explain about tristate constants?

587


Sub link() Dim k As Integer Dim rand As Integer Dim URL As String Dim foldernum As Integer Dim folderstring As String Dim filenum As Integer Dim filestring As String k = 1 'for AC Numbers For i = 11 To 40 foldernum = 0 foldernum = 1000 + i folderstring = CStr(foldernum) folderstring = Mid(folderstring, 2, 3) folder = "ac" & folderstring 'folderstring = Sheets(2).Cells(i, 1) ' for Number of Random files For j = 1 To 10 rand = Int(Rnd * (200 - 1) + 1) filenum = 0 filenum = 1000 + rand filestring = CStr(filenum) filestring = Mid(filestring, 2, 3) 'URL = "http://ceobihar.nic.in/PSCDROM/ac" & folderstring & "/i" & folderstring & "0" & filestring & ".pdf" URL = "http://www.elections.tn.gov.in/pdfs/dt1/" & folder & "/" & folder & filestring & ".pdf" ' URL =http://www.wb.nic.in/wbeco/EROLLS/PDF/English/A001/a0010105 .pdf Cells(k, 1) = folderstring Cells(k, 2) = folder Cells(k, 3) = filestring Cells(k, 3) = URL k = k + 1 Next j Next i End Sub plz define it

2245






Explain about filter expression?

569


What is the difference between do until loop and do while loop?

545


Is vbscript language a case-sensitive language and what does it mean?

550


what is the difference between modular and data and keyword driven framework

1745


What is Procedure or Subroutine in VB Script?

606


Explain the extension .hta?

546


when we use filter funtiom invb script(QTP)

2304


What is the scope of a constant declared using public?

567


how does vb script help in web page designing? explain with example.

1590


how to check whether link is disabled in QTP??

5635