Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- primos = []
- fact_prim = []
- def criba(num):
- global primos
- n = num
- num = int(sqrt(num))
- l = [0]*(num+1)
- for i in range(2,num+1):
- if l[i] == 0:
- primos.append(i)
- for j in range(i*2,num+1,i):
- l[j] = 1
- def factores_primos(num):
- while not num in primos:
- for i in primos:
- if num%i==0:
- num //= i
- fact_prim.append(i)
- break
- fact_prim.append(num)
- def main():
- num = 956743235
- criba(num)
- factores_primos(num)
- #print ("Factores primos: ", fact_prim)
- d = dict()
- for i in fact_prim:
- d[str(i)] = d.get(str(i),0) + 1
- factores2 = set()
- factores3 = set()
- for i in d.keys():
- factores1 = set()
- for j in range(d[i]+1):
- factores1.add(int(i)**j)
- for f2 in factores2:
- for f1 in factores1:
- factores3.add(f2*f1)
- for f in factores1:
- factores2.add(f)
- respuesta = set([i for i in factores3])
- for f3 in factores3:
- respuesta.add(num//f3)
- print(sorted(respuesta))
- if __name__ == "__main__":
- main()
- input()
- [1, 5, 7, 31, 35, 155, 217, 593, 1085, 1487, 2965, 4151, 7435, 10409, 18383, 20755, 46097, 52045, 91915, 128681, 230485, 322679, 643405, 881791, 1613395, 4408955, 6172537, 27335521, 30862685, 136677605, 191348647, 956743235]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement