Modular Help

Quick question. I know that the number of units + number of zero divisors + 1 = n for Z mod n.
When n is the product of three distinct primes, how can I make the coding so Sage will return the number of zero divisors. I'm at a standstill and would appreciate any help. Thanks :]

1 answer

This seems more like a homework question than something about Sage. Sage won't be able to give you a formula for the number of zero divisors of Z mod (pqr) (although one exists); you need some more theoretical knowledge for that. However, here is a naive function which counts the number of zero divisors of Z mod n: