Created
December 15, 2021 06:34
-
-
Save hmmhmmhm/004f8f356eb395e3e21edea3294a0aa5 to your computer and use it in GitHub Desktop.
Modulo in javascript (and typescript).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ts | |
| const mod = (n: number, m: number) => { | |
| let r = n % m; | |
| return Math.floor(r >= 0 ? r : r + m); | |
| }; | |
| // js | |
| const mod = (n, m) => { | |
| let r = n % m; | |
| return Math.floor(r >= 0 ? r : r + m); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment