Example #1
0
/*
 * Version: 12.07.20 (Generic Smart Readable)
 * Finds the first triangle number with over X factors.
 */
int solution(const int X)
{
        int i;
        int current = 0;
        for(i=1; divisor_count(current) <= X; i++)
                current = i * (i + 1) / 2;
                
        return current;
}
Example #2
0
File: main.cpp Project: CCJY/coliru
int main()
{
    auto triangle = 1LU;
    for (auto i = 2LU; i < 10; ++i)
    {
        triangle += i;
        auto c = divisor_count(triangle);
        std::cout << "i: " << i << ", triangle: " << triangle << ", divisor_count: " << divisor_count << std::endl;
        if (c > 500)
        {
            std::cout << triangle << std::endl;
            return 0;
        }
    }
}
Example #3
0
File: main.cpp Project: CCJY/coliru
int main()
{
    auto triangle = 1LU;
    for (auto i = 2LU; ; ++i)
    {
        triangle += i;
        auto c = divisor_count(triangle);
        if (i % 101 == 0)
        {
            std::cout << triangle << ": " << c << std::endl;
        }
        if (c > 100)
        {
            std::cout << triangle << std::endl;
            return 0;
        }
    }
}