I am a thirteen-year-old who is learning programming. I know Javascript and Python pretty well, but I mostly program Javascript using Node.js as my compiler.
I have a pretty naïve question. I am writing an implementation of a circular buffer, and I need to know the remainder when -7 is divided by 3. I went to a Node.js console(version 11.1.0) and a Python console(Python 3.7) and typed in -7 % 3
. In the Node.js console, it printed -1
, but in the Python console, it printed 2
. My question is partially mathematical: Which answer is correct, -1 or 2?