Factorials, Permutations, Combinations

Date Submitted Sat. Apr. 22nd, 2006 11:17 AM
Revision 4 of 4
Beginner Utsawin
Tags "ASP.NET 2.0" | combinations | factorials | math | permutations
Comments 3 comments
Go easy on me, my first snippet - plus I am new to VB.NET 2.0... with only basic knowledge of classic VB... Just want to mention that the Permutations function is not actually mine - found it online... (credit where credit's due)

Fairly simple stuff, but had me pulling my hair out - Even Excel has a COMBI function out of the box!

    Public Function Factorial(ByVal factor As Double) As Double
        If factor = 0 Then
            Factorial = 1
            Factorial = factor * Factorial(factor - 1)
        End If
        Exit Function
        Return (Factorial)
    End Function

    Public Function Permutations(ByVal a As Double, ByVal b As Double) As Double
        Permutations = Factorial(a) / Factorial(a - b)
        Return (Permutations)
    End Function

    Public Function Combinations(ByVal a As Integer, ByVal b As Integer) As Integer
        Combinations = Permutations(a, b) / Factorial(b)
    End Function

Jules Honour

..:: It's better to look stupid, than open your mouth and remove all doubt ::..


Comments Oops...
Sat. Apr. 22nd, 2006 11:30 AM    Beginner Utsawin
Comments I think somethig went wrong?
Mon. Apr. 17th, 2006 2:52 PM    Syntax Master dannyboy
Comments Where's the snippet?
Mon. Apr. 17th, 2006 12:49 PM    Coder mattrmiller


Votes Down