Results 1 to 3 of 3

Thread: what's the problem pls help me

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    2

    what's the problem pls help me

    in bv mathematic fuction if i wan to use factorial so what is the keyword for factorial???

    i use "prev = fact(n) / (fact(n - r))" , why i does not work???

    instead of using "fact" what shold i use...

    thank you for those who really can help me answer this...

    thanks alot in advance 1st...

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: what's the problem pls help me

    You can use this function.

    VB Code:
    1. Public Function Factorial(intNbr As Integer) As Long
    2.  
    3.     Dim counter As Integer
    4.     Dim strAnswer As String
    5.    
    6.     counter = intNbr
    7.     Factorial = counter
    8.     Do While counter > 1
    9.         counter = counter - 1
    10.         Factorial = Factorial * counter
    11.     Loop
    12.  
    13. End Function

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: what's the problem pls help me

    or this one if you like recursive code better
    VB Code:
    1. Public Function Factoral(ByVal nNum As Integer) As Long
    2.     If nNum = 1 Or nNum = 0 Then
    3.         Factorial = 1
    4.     Else
    5.         Factorial = nNum * Factorial(nNum - 1)
    6.     End If
    7. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width