Page 1 of 1

Report a wrong answer

Posted: Thu Dec 18, 2025 3:33 pm
by amir_namdari_1998
hello
I think the answer for problem https://projecteuler.net/problem=12" is wrong.
if you solve the problem with this way:
solution 1
python
counter = 2
for i in range(2, int(n / 4) + 1):
counter += 2
The answer is different with:
solution 2
python
counter = 2
for i in range(2, int(n**0.5) + 1):
counter += 2
The obtained result (solution 1) differs from the accepted answer (solution 2).
The answer should be resulted from solution 1. because it's valid for all conditions and smaller than the accepted one(The problem wants the smallest one).

Re: Report a wrong answer

Posted: Thu Dec 18, 2025 6:36 pm
by DJohn
The big red box at the top of the page says very clearly
In particular don't post any code fragments or results.
This is not the place to post code.

Problem 12 is 23 years old, and has been solved by over 240,000 people. If the accepted answer was wrong, it's very likely that at least one of those people would have noticed by now. It's far more likely that you've made some mistake.

And indeed, you have. The code you posted is incomplete, but I think I can work out what the rest should be. You're making an assumption there that I can't think of any justification for - not surprisingly, as it's getting the wrong result.