> 
> **Possible Duplicate:**  
> 
> [Project Euler Problem 12 - C++](https://stackoverflow.com/questions/3808148/project-euler-problem-12-c) 
> 
> 
> 

I've been working on Euler problems and hit a wall with problem 12. I read up on some mathematical solutions for large numbers but I'm still not getting the right answer. This is my code:

```
#include <iostream>
using namespace std;

int divisorCount(const unsigned long long x)
{
    int divizers = 0;
    unsigned long long i = 1;
    while(i <= x/i)
    {
        if(x % i == 0)
        {
            divizers++;
        }
        i++;
    }
    return divizers;
}

int main()
{
    bool test;
    unsigned long long total = 0, spread = 1;
    int divisors = 1;

    while(divisors < 501)
    {
        total+=spread;
        divisors = divisorCount(total);
        spread++;
        if(divisors > 501)
            cout << total << " " << spread << " " << divisors << endl;
    }

    cout << total << " is divisible by 500+ numbers" << endl;
    system("pause");
    return 0;
}

```

Any suggestions?