Does anyone have a good theorem to find the amount of factors in a number? For example, there are 9 factors in 100
I can't really think of a better way to search for amount of factors in n:
pseudocode:
divide n by all numbers 2 to sqrt(n) to see if any are integers
double the amount, add 2, subtract 1 if sqrt(n) is an integer
e.g: for 100
divide by 2,3,4,5,6,7,8,9,10, in the results there are 4 integers, and sqrt is an integer
4 x 2 + 2 - 1 = 9 factors in 100
Is this method frowned upon by programmers? Or at least acceptable?
This post was edited by Foxic on Apr 12 2013 06:56pm