Lesson 4 of 15
Cyclic Groups
Cyclic Groups
A group is cyclic if there exists an element such that every element of can be written as a power of :
The element is called a generator of .
Order of an Element
The order of an element in a group , written , is the smallest positive integer such that (identity).
In under addition, the order of is:
Generators of
An element is a generator of if and only if . The number of generators equals (Euler's totient function).
from math import gcd
def order_in_Zn(a, n):
return n // gcd(a, n)
def generators_of_Zn(n):
return [a for a in range(n) if gcd(a, n) == 1]
Fundamental Theorem of Cyclic Groups
Every subgroup of a cyclic group is cyclic. Furthermore, for each divisor of , there is exactly one subgroup of of order .
Example:
- Generators: (elements coprime to 8)
- Orders: , , ,
Your Task
Implement element_order(a, n) for the order of in , is_cyclic_generator(a, n) to check if generates , and all_generators(n) returning the sorted list of all generators.
Pyodide loading...
Loading...
Click "Run" to execute your code.