Hi all,
I'm currently working on project euler problem 12 and my code is working, only problem is that it is to slow.
C++ Code:
  1. int  getDivisors(int n)
  2. {
  3.     int c = 0; // the counter
  4.     for (int i = 1; i < n; i++)
  5.     {
  6.         if (n % i == 0)
  7.             c++;
  8.     }
  9.     return c;
  10. }
Quick explanation, It is a loop that goes from 1 to the value you gave the function and if the value divided by the Iterator is 0 it increments the counter.
this works but gets extremely slow when large digits are involved (I did a profiling test and 99.9% of my programs running time is spent in this function)

Is there a way to calculate the number of divisors of a number instead of my brute force attempt ?