# Use of 'mod' versus '%' in Sage.

I would like to better understand the use of 'mod' in Sage.

The function 'mod', as defined in sage/rings/finite_rings/integer_mod, returns mod(a, 0) = a, which is fine.

On the other hand, in sage/arith/misc, the function 'quadratic_residues' is defined as

```
sorted(set(ZZ((a*a) % n) for a in range(n // 2 + 1)))
```

Thus, if n = 0, a ZeroDivisionError is thrown. If, on the other hand, the function had been implemented with 'mod', there would be no error and 0 would be returned. This variant looks more advantageous for me.

Test:

```
for n in range(0, 11):
print(sorted(set(ZZ(mod((a*a), n)) for a in range(n // 2 + 1))))
```

This is a suggestion to amend Sage's behaviour. May I suggest to discuss it on sage-support ?

Thanks Emmanuel, I might do that. Is there a general recommendation in which cases to use AskSage and in which cases sage-support?