Fastest way to calculate primes in C#?

后端 未结 8 927
孤独总比滥情好
孤独总比滥情好 2021-02-03 09:56

I actually have an answer to my question but it is not parallelized so I am interested in ways to improve the algorithm. Anyway it might be useful as-is for some people.

8条回答
  •  半阙折子戏
    2021-02-03 10:35

    Are you trying to find new primes? This may sound stupid, but you might be able to load up some sort of a data structure with known primes. I am sure someone out there has a list. It might be a much easier problem to find existing numbers that calculate new ones.

    You might also look at Microsofts Parallel FX Library for making your existing code multi-threaded to take advantage of multi-core systems. With minimal code changes you can make you for loops multi-threaded.

提交回复
热议问题