You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
749 B

7 years ago
  1. import saveto
  2. from math import log
  3. from math import factorial
  4. primes = tuple(saveto.load('primes'))
  5. print('Made tuple')
  6. def factor(c):
  7. output = {}
  8. if c in primes:
  9. output = {c:1}
  10. else:
  11. n = c
  12. count_0 = 0
  13. while n != 1:
  14. while n%primes[count_0] != 0:
  15. count_0 += 1
  16. b = primes[count_0]
  17. p = round(log(n,b))
  18. while n%(b**p) != 0:
  19. p -= 1
  20. n /= b**p
  21. count_0 += 1
  22. if p > 0:
  23. output[b] = int(p)
  24. return output
  25. ##output = [{0:1},{1:1}]
  26. ##for i in range(2,30):
  27. ## output.append(factor(i))
  28. ## if i%1000 == 0:
  29. ## print(i)
  30. ##print(output)
  31. ##print('{:,}'.format(primes[-1]))