Posted By

Scooter on 06/14/08


Tagged

math


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Factorial


Published in: ASP 






URL: http://reusablecode.blogspot.com/2008/06/factorial.html

Expand | Embed | Plain Text
  1. <%
  2. ' ASP Mathematics Library - Factorial
  3. '
  4. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  5. '
  6. ' This work is licensed under the Creative Commons Attribution License. To view
  7. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  8. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  9. ' 94305, USA.
  10.  
  11. ' Determine the factorial for a given number
  12. function factorial(x)
  13. dim result
  14.  
  15. result = 1
  16.  
  17. if x > 1 then
  18. for i = 2 to x
  19. result = result * i
  20. next
  21. end if
  22.  
  23. factorial = result
  24. end function
  25.  
  26. ' Returns the number of combinations, without regard to order, of y items that can be made from a pool of x items.
  27. ' Requires factorial()
  28. function combinatorial(x, y)
  29. if (x >= y) and (y > 0) then
  30. combinatorial = factorial(x) / factorial(y) / factorial(x - y)
  31. else
  32. combinatorial = 0
  33. end if
  34. end function
  35.  
  36. ' Returns the number of permutations, with regard to order, of y items that can be made from a pool of x items.
  37. ' Requires factorial()
  38. function permutations(x, y)
  39. permutations = factorial(x) / factorial(x - y)
  40. end function
  41. %>

Report this snippet 

You need to login to post a comment.