Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Algorytm Euklidesowy
- def euclides(x,y):
- temp = 0
- rest1 = 0
- rest2 = 0
- if x > y:
- rest1 = x % y
- rest2 = y
- elif x == y:
- return x
- else:
- rest1 = y % x
- rest2 = x
- while True:
- if rest1 > rest2:
- rest1 %= rest2
- else:
- rest2 %= rest1
- if rest1 == 0:
- return rest2
- elif rest2 == 0:
- return rest1
- # Rozklad na czynniki pierwsze
- # Zwraca w liscie, od gory
- def distribution(x):
- ite = 2
- dividers = []
- while x > 1:
- if x % ite == 0:
- x /= ite
- dividers.append(ite)
- ite = 2
- else:
- ite += 1
- return dividers
- # Strukturyzja do postaci slownika klucz-wartosc
- # Gdzie klucz to podstawa, a wartosc wykladnik (ilosc wystapien poszczegolnego dzielnika w rozkladzie)
- def structurize_divs(divers):
- result = {}
- for i in divers:
- result[i] = divers.count(i)
- return result
- # Funkcja Eulera (nie twierdzenie)
- def euler(data):
- result = 1
- for base in data:
- result *= pow(base, data[base]-1)*(base-1)
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement