#python vs golang modulus
6 messages · Page 1 of 1 (latest)
!go go fmt.Println(-10286371 % 12289)
oh bot doesnt work
In computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another (called the modulus of the operation).
Given two positive numbers a and n, a modulo n (often abbreviated as a mod n) is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor....
found solution
// Positive modulo, returns non negative solution to x % d
func Pmod(x, b int) int {
x = x % b
if x >= 0 {
return x
}
if b < 0 {
return x - b
}
return x + b
}