Published in: ASP
|
|
|
URL: http://reusablecode.blogspot.com/2008/06/factorial.html
Expand |
Embed | Plain Text
<% ' ASP Mathematics Library - Factorial ' ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA. ' Determine the factorial for a given number function factorial(x) dim result result = 1 if x > 1 then for i = 2 to x result = result * i next end if factorial = result end function ' Returns the number of combinations, without regard to order, of y items that can be made from a pool of x items. ' Requires factorial() function combinatorial(x, y) if (x >= y) and (y > 0) then combinatorial = factorial(x) / factorial(y) / factorial(x - y) else combinatorial = 0 end if end function ' Returns the number of permutations, with regard to order, of y items that can be made from a pool of x items. ' Requires factorial() function permutations(x, y) permutations = factorial(x) / factorial(x - y) end function %>
You need to login to post a comment.
