forked from kalmar/DALGLI0
Prześlij pliki do ''
This commit is contained in:
parent
16f4649ea6
commit
2542773fa7
57
zad1.py
Normal file
57
zad1.py
Normal file
@ -0,0 +1,57 @@
|
||||
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()
|
Loading…
Reference in New Issue
Block a user