[Solved] Project Euler 8 C++ Debug [closed]
Adding to Igor Tandetnik’s answer: There is another problem, (n[i]-‘0’)*(n[i+1]-‘0’)*(n[i+2]-‘0’)*(n[i+3]-‘0’)*(n[i+4]-‘0’)*(n[i+5]-‘0’)*(n[i+6]-‘0’)*(n[i+7]-‘0’)*(n[i+8]-‘0’)*(n[i+9]-‘0’)*(n[i+10]-‘0’)*(n[i+11]-‘0’)*(n[i+12]-‘0’) is calculated as an int and therefore it will overflow for example at i == 88. You have to cast the first value to unsigned long long to have the whole calculation as unsigned long long. #include <iostream> #include <string> using namespace std; int main(){ … Read more