Lesson 9 of 15
Rings
Rings
A ring is a set with two binary operations satisfying:
- is an abelian group
- Multiplication is associative:
- Distributive laws hold:
If multiplication is commutative, we call it a commutative ring. If there is a multiplicative identity , we call it a ring with unity.
Example:
The integers modulo form a commutative ring with unity under addition and multiplication mod .
def Zn_add(a, b, n):
return (a + b) % n
def Zn_mul(a, b, n):
return (a * b) % n
Zero Divisors
An element is a zero divisor if there exists such that .
In : , so both 2 and 3 are zero divisors.
In (prime modulus): there are no zero divisors — this makes it an integral domain.
Units
An element is a unit (invertible) if there exists such that . The units form a group under multiplication, denoted .
Your Task
Implement zero_divisors(n) returning the sorted list of zero divisors in , and units(n) returning the sorted list of units (multiplicatively invertible elements).
Pyodide loading...
Loading...
Click "Run" to execute your code.