I'm trying to solve [Project Euler problem 401](http://projecteuler.net/problem=401). They only way I could find a way to solve it was brute-force. I've been running this code for like 10 mins without any answer. Can anyone help me with ideas improve it.

Code:

```
#include <iostream>
#include <cmath>
#define ull unsigned long long

using namespace std;

ull sigma2(ull n);
ull SIGMA2(ull n);

int main()
{
    ull ans = SIGMA2(1000000000000000) % 1000000000;

    cout << "Answer: " << ans << endl;

    cin.get();
    cin.ignore();

    return 0;
}

ull sigma2(ull n)
{
    ull sum = 0;
    for(ull i = 1; i<=floor(sqrt(n)); i++)
    {
        if(n%i == 0)
        {
            sum += (i*i)+((n/i)*(n/i));
        }
        if(i*i == n)
        {
            sum -= n;
        }
    }
    return sum;
}

ull SIGMA2(ull n)
{
    ull sum = 0;
    for(ull i = 1; i<=n; i++)
    {
        sum+=sigma2(i);
    }
    return sum;
}

```