Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- final version
- """
- from functools import reduce
- def common_factors(*args):
- result = []
- for arg in args:
- result.append([x for x in range(1, arg) if arg % x == 0])
- return sorted(list(reduce(lambda x,y: set(x) & set(y), result)))
- """
- version 2
- """
- import time
- from functools import reduce
- def factor(arg):
- result=[]
- for x in range(1,arg+1):
- if arg % x == 0:
- result.append(x)
- return set(result)
- def common_factor(func, *a):
- arr=list(map(func, a))
- return list(reduce((lambda x,y: x & y), arr))
- """
- version 1 (for noobs)
- """
- def f(a):
- m=[]
- A=a+1
- div=list(range(1,A))
- for x in div:
- if a%x==0:
- m+=[x]
- return m
- def F(*b):
- L=[]
- for x in b:
- L+=[f(x)]
- return L
- def func(L):
- if len(L)==1:
- return L
- q=len(L)-1
- x=list(set(L[q])&set(L[q-1]))
- return func(L[:-2]+[x])
- print(func(F(50,40,60)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement