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.
For 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.
This is the issue I had to resolve. Luckily for me, my only division was a divide by two so I converted it to a bitwise right-shift.
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
For 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.
This is the issue I had to resolve. Luckily for me, my only division was a divide by two so I converted it to a bitwise right-shift.