Prime factor of 300 000 000 000?

前端 未结 19 786
无人及你
无人及你 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:01

    Here is an XSLT solution!

    This XSLT transformation takes 0.109 sec.

    
     
    
     
    
    
     
       
     
    
     
       
    
       
     
    
    

    This transformation produces the correct result (the maximum prime factor of 600851475143) in just 0.109 sec.:

    6857

    The transformation uses the f:sqrt() and f:isPrime() defined in FXSL 2.0 -- a library for functional programming in XSLT. FXSL is itself written entirely in XSLT.

    f:isPrime() uses Fermat's little theorem so that it is efficient to determine primeality.

提交回复
热议问题