Getting Factors of a Number

前端 未结 11 1934
误落风尘
误落风尘 2020-12-30 11:53

I\'m trying to refactor this algorithm to make it faster. What would be the first refactoring here for speed?

public int GetHowManyFactors(int numberToCheck         


        
11条回答
  •  孤城傲影
    2020-12-30 12:38

    An easy to implement algorithm that will bring you much farther than trial division is Pollard Rho

    Here is a Java implementation, that should be easy to adapt to C#: http://www.cs.princeton.edu/introcs/78crypto/PollardRho.java.html

提交回复
热议问题