Sequence of primes by trial division: Difference between revisions
Sequence of primes by trial division (view source)
Revision as of 17:11, 16 September 2021
, 2 years ago→{{header|C sharp}}: tweaked to work properly with limits other than 100.
No edit summary |
m (→{{header|C sharp}}: tweaked to work properly with limits other than 100.) |
||
Line 513:
}
static IEnumerable<int> Primes(int limit) => Enumerable.Range(2, limit-
static bool IsPrime(int n) => Enumerable.Range(2, (int)Math.Sqrt(n)-1).All(i => n % i != 0);
}</lang>
|