Project Euler problem 56


[Simple brute force method][2]

Everything looks alright but the answer is incorrect. It should be 972. Please help me find the error. Thanks.


Answer is indeed 972!!

Here is the fixed code:

The thing you were doing “wrong” is that in your for loops you were iterating from range(1,99), while it should be from 1 to 100.

This is because range() function in Python is the same as:

range(a,b) -> [a, b[

That is, upper limit is not accounted in the range.

Best regards,


1 Like