#Finding product in a series

10 messages · Page 1 of 1 (latest)

dense smelt
#

https://projecteuler.net/problem=8

int main()
{
    std::string value[20];

    init_series_PE8(value);

    unsigned int long long current_max = 0;

    int max_row = 0, max_start_index = 0;

    for (int i = 0; i < 20; ++i)
    {
        std::cout << "ROW " << i+1 << "\n---------------------\n";
        for (int j = 0; j < (50-11); ++j)
        {

            unsigned int long long accumulator = 1;

            for (int k = 0; k < 13; ++k)
            {


                accumulator *= atoi(value[i][j + k]);
            }

            if (accumulator > current_max)
            {
                current_max = accumulator;
            }

        }
    }

    std::cout << "Max is: " << current_max << "\n";

}

Any ideas why the above code is displaying 2490394032, which isn't the right value

elfin kayakBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dense smelt
#

the correct answer should be 23514624000

#

I am multiplying properly, atleast i think so. I am iterating through each row, since they need to be adjacent

#

I assume by adjacent they do not mean vertically adjacent

iron cosmos
#

It's a 1000-digit number

#

Not a 20-row-50-column-digit number :p

#

So yeah

#

Concatenate the lines, remove one loop and you should be good to go

dense smelt