Ad
  • Default User Avatar

    Your code uses the floating point number division operator / instead of // for integer division since python version 3.
    In python versions 2.x / could mean integer division, but this has been changed incompatibly since version 3.
    You must calculate with integers only, not floats. Then it works.
    The problem is that floating point numbers have only limited precision, they can't store verly large integers.
    In python, integers can be as large as you want, but always divide using // to get an integer result.