Prime factor of 300 000 000 000?

前端 未结 19 753
无人及你
无人及你 2021-01-03 10:23

I need to find out the prime factors of over 300 billion. I have a function that is adding to the list of them...very slowly! It has been running for about an hour now and i

19条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 11:06

    I spent some time on this since it just sucked me in. I won't paste the code here just yet. Instead see this factors.py gist if you're curious.

    Mind you, I didn't know anything about factoring (still don't) before reading this question. It's just a Python implementation of BradC's answer above.

    On my MacBook it takes 0.002 secs to factor the number mentioned in the question (600851475143).

    There must obviously be much, much faster ways of doing this. My program takes 19 secs to compute the factors of 6008514751431331. But the Factoris service just spits out the answer in no-time.

提交回复
热议问题