Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. primos = []
  4. fact_prim = []
  5. def criba(num):
  6. global primos
  7. n = num
  8. num = int(sqrt(num))
  9. l = [0]*(num+1)
  10.  
  11. for i in range(2,num+1):
  12. if l[i] == 0:
  13. primos.append(i)
  14. for j in range(i*2,num+1,i):
  15. l[j] = 1
  16.  
  17. def factores_primos(num):
  18. while not num in primos:
  19. for i in primos:
  20. if num%i==0:
  21. num //= i
  22. fact_prim.append(i)
  23. break
  24. fact_prim.append(num)
  25.  
  26. def main():
  27. num = 956743235
  28. criba(num)
  29. factores_primos(num)
  30. #print ("Factores primos: ", fact_prim)
  31. d = dict()
  32. for i in fact_prim:
  33. d[str(i)] = d.get(str(i),0) + 1
  34.  
  35. factores2 = set()
  36. factores3 = set()
  37.  
  38. for i in d.keys():
  39. factores1 = set()
  40. for j in range(d[i]+1):
  41. factores1.add(int(i)**j)
  42.  
  43. for f2 in factores2:
  44. for f1 in factores1:
  45. factores3.add(f2*f1)
  46.  
  47. for f in factores1:
  48. factores2.add(f)
  49.  
  50. respuesta = set([i for i in factores3])
  51. for f3 in factores3:
  52. respuesta.add(num//f3)
  53. print(sorted(respuesta))
  54.  
  55. if __name__ == "__main__":
  56. main()
  57. input()
  58.  
  59. [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