Project Euler #1: Multiples of 3 and 5

  • + 76 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.