[Python] Why is it valid to only mod at the end?
I got a wrong submission for trying to mod as I go. For example:\n\ndef recur(i):\n     ....\n\t calc = recur(i+1) % mod\n\t return calc\n\n\nbut my submission 
I got a wrong submission for trying to mod as I go. For example:\n```\ndef recur(i):\n     ....\n\t calc = recur(i+1) % mod\n\t return calc\n```\n\nbut my submission passes when at the very end I just mod the answer I arrived at.\n```\ndef recur():\n\t...\n\treturn calc\n\ndef maxSum():\n     ans = recur(0)\n\t return ans % mod\n```\n\nWouldn\'t this potentially overflow? How is it that we only need to mod at the very end?
[]