Factorial


Private Sub Factorial()
Dim intNum, intFactorial, intI As Integer

intNum = 5
intFactorial = 1
For intI = 1 To intNum
intFactorial = intFactorial * intI
Next
MessageBox.Show(intFactorial)
End Sub


The above subroutine gives factorial of a number.Here I have given 5 as input,you may change it as per your requirement.


Comments

Guest Author: ATL20 Feb 2013

Private Function Factorial(n As Integer)
Dim intFactorial, intI As Integer
intFactorial = 1
For intI = 1 To n
intFactorial *= intI
Next
Return intFactorial
End Sub



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: