Skip to content

Instantly share code, notes, and snippets.

@treeform
Last active May 18, 2018 22:33
Show Gist options
  • Save treeform/51db7a31b1bb64daf5bdb662a9b8e6c8 to your computer and use it in GitHub Desktop.
Save treeform/51db7a31b1bb64daf5bdb662a9b8e6c8 to your computer and use it in GitHub Desktop.
proc pythonMod(n, M: int): int = ((n mod M) + M) mod M
assert pythonMod(1, -4) == -3
assert pythonMod(-1, 4) == 3
assert pythonMod(-1, -4) == -1
assert pythonMod(1, 4) == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment