forked from kalmar/DALGLI0
58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
def odwracalny(i,n):
|
|
for x in range(n):
|
|
if((x * i) % n == 1):
|
|
return True
|
|
return False
|
|
|
|
def el_odwracalne(n):
|
|
lista = []
|
|
for i in range(n):
|
|
if(odwracalny(i,n)):
|
|
lista.append(i)
|
|
return(lista)
|
|
|
|
def dzieli_zero(i,n):
|
|
for x in range(1,n):
|
|
if((x * i) % n == 0):
|
|
return True
|
|
return False
|
|
|
|
def dzielniki_zera(n):
|
|
lista = []
|
|
for i in range(n):
|
|
if(dzieli_zero(i,n)):
|
|
lista.append(i)
|
|
return(lista)
|
|
|
|
def nilpotent(i,n):
|
|
for x in range(1,n):
|
|
if((i**x) % n == 0):
|
|
return True
|
|
return False
|
|
|
|
def el_nilpotentne(n):
|
|
lista = []
|
|
for x in range(n):
|
|
if(nilpotent(x,n)):
|
|
lista.append(x)
|
|
return(lista)
|
|
|
|
|
|
def el_idempotentne(n):
|
|
lista = []
|
|
for x in range(n):
|
|
if((x*x) % n == x):
|
|
lista.append(x)
|
|
return(lista)
|
|
|
|
def main():
|
|
n = int(input("Podaj n: "))
|
|
print("Z/"+str(n))
|
|
print("elementy odwracalne "+str(el_odwracalne(n)))
|
|
print("dzielniki zera "+str(dzielniki_zera(n)))
|
|
print("elementy nilpotentne "+str(el_nilpotentne(n)))
|
|
print("elementy idempotentne "+str(el_idempotentne(n)))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|