We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
or anyone who is using Python3. If you've already converted from the iterive to the O(1) solution but you're still getting the "wrong answer" with Test Cases 2 and 3 here is why:
When you divide integers in python 3, the answer is converted automatically to a float. Becuase Test Cases 2 and 3 involve very large numbers, when you convert back to integer, there will be a huge rounding error and your answers will be wrong.
so rather than dividing with 2 or multiplying by 0.5 just do right shift by 1.
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
or anyone who is using Python3. If you've already converted from the iterive to the O(1) solution but you're still getting the "wrong answer" with Test Cases 2 and 3 here is why: When you divide integers in python 3, the answer is converted automatically to a float. Becuase Test Cases 2 and 3 involve very large numbers, when you convert back to integer, there will be a huge rounding error and your answers will be wrong. so rather than dividing with 2 or multiplying by 0.5 just do right shift by 1.