fork download
  1. import time
  2. def divisores(num):
  3. for i in range(1, num//2+1):
  4. if num % i == 0:
  5. yield i
  6. yield num
  7.  
  8. num = 47587950
  9.  
  10. inicio = time.time()
  11. print(list(divisores(num)))
  12. print("Fim da execução maneira 1: %s segundos" % round((time.time() - inicio),4))
  13.  
  14. inicio = time.time()
  15. print([i for i in range(1, num//2+1) if num%i==0])
  16. print("Fim da execução maneira 2: %s segundos" % round((time.time() - inicio),4))
Success #stdin #stdout 3.64s 28384KB
stdin
Standard input is empty
stdout
[1, 2, 3, 5, 6, 9, 10, 15, 18, 25, 30, 45, 50, 75, 90, 150, 225, 450, 105751, 211502, 317253, 528755, 634506, 951759, 1057510, 1586265, 1903518, 2643775, 3172530, 4758795, 5287550, 7931325, 9517590, 15862650, 23793975, 47587950]
Fim da execução maneira 1: 1.7259 segundos
[1, 2, 3, 5, 6, 9, 10, 15, 18, 25, 30, 45, 50, 75, 90, 150, 225, 450, 105751, 211502, 317253, 528755, 634506, 951759, 1057510, 1586265, 1903518, 2643775, 3172530, 4758795, 5287550, 7931325, 9517590, 15862650, 23793975]
Fim da execução maneira 2: 1.9021 segundos