Brute-force, single-threaded prime factorization

前端 未结 7 645
误落风尘
误落风尘 2020-12-07 22:08

Up for consideration is the following function which can be used to (relatively quickly) factor a 64-bit unsigned integer into its prime factors. Note that the factoring is

相关标签:
7条回答
  • 2020-12-07 22:50

    The natural generalization is to precompute skippages using more known primes than just 2 and 3. Like 2, 3, 5, 7, 11, for a pattern period of 2310 (huh, nice number). And perhaps more, but it has diminishing returns -- a graph of run times could establish exactly where the precomputation starts to have negative impact, but of course it depends on the number of numbers to factor...

    Hah, I leave the coding details to you folks. :-)

    Cheers & hth.,

    – Alf

    0 讨论(0)
提交回复
热议问题