An obvious method for finding the proper divisors of the number N is to consider all of the values between 1 and N/2 and see which ones divide into N evenly. The following method takes this approach:
// Examine values between 1 and number / 2.private List<long> Method1(long number){ checked { List<long> divisors = new List<long>(); long limit = number / 2; for (long factor = 1; factor <= limit; factor++) { if (number % factor == 0) divisors.Add(factor); } return divisors; }}
This method is straightforward, but it can be slow if the number is large. For example, if the number is 10 billion, then the method must examine 5 billion values.
In contrast, the prime factoring algorithms described earlier in this chapter only needed ...