We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
There's nothing strange (and this goes for every language), as the definition of Euclidean division requires remainder to be within [0, |b|) range. For the remainder to be positive, use r = ((a % b) + b) % b formula.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sum of Odd Elements
You are viewing a single comment's thread. Return to all comments →
There's nothing strange (and this goes for every language), as the definition of Euclidean division requires remainder to be within
[0, |b|)
range. For the remainder to be positive, user = ((a % b) + b) % b
formula.