C# LINQ判断素数的简单源码

303 阅读1分钟

下面的代码是关于C# LINQ判断素数的简单的代码。

static bool IsPrime(int n) { return Enumerable.Range(2, (int) Math.Sqrt(n)-1).All(i => n%i != 0); }