Project Euler problem 56

[Problem][1]

[Simple brute force method][2]

Everything looks alright but the answer is incorrect. It should be 972. Please help me find the error. Thanks.
[1]: http://projecteuler.net/problem=56
[2]: http://ideone.com/bzssO6

Hello,

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,

Bruno

1 Like