Posted By

Scooter on 06/28/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


Factors


Published in: ASP 






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

Expand | Embed | Plain Text
  1. <%
  2. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Returns an array containing all factors for a given integer.
  10. function factors(x)
  11. dim i
  12. dim arrFactors
  13. arrFactors = Array()
  14.  
  15. for i = 2 to x
  16. if x mod i = 0 then
  17. redim preserve arrFactors(UBound(arrFactors) + 1)
  18. arrFactors(UBound(arrFactors)) = i
  19. end if
  20. next
  21.  
  22. factors = arrFactors
  23. end function
  24. %>

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: Scooter on September 28, 2008

Fixed a "subscript out of range" bug.

You need to login to post a comment.

Download royalty free graphics