ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 10 Dec 2010 02:59:08 +0100Modular Helphttps://ask.sagemath.org/question/7755/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 :]Fri, 10 Dec 2010 02:31:05 +0100https://ask.sagemath.org/question/7755/modular-help/Answer by Mike Hansen for <p>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 :]</p>
https://ask.sagemath.org/question/7755/modular-help/?answer=11844#post-id-11844This 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 (p*q*r) (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:
def number_of_zero_divisors(n):
zero_divisors = 0
for i in range(1, n):
for j in range(1, n):
if (i*j) % n == 0:
zero_divisors += 1
break
return zero_divisors
Here is some sample output:
sage: number_of_zero_divisors(2*3*5)
21
sage: number_of_zero_divisors(5*7*11)
144
Fri, 10 Dec 2010 02:59:08 +0100https://ask.sagemath.org/question/7755/modular-help/?answer=11844#post-id-11844