Strong and weak primes: Difference between revisions

m
Line 152:
var primes = PrimeGenerator(10_000_100).ToList();
var strongPrimes = from i in Range(1, primes.Count - 2) where primes[i] > (primes[i-1] + primes[i+1]) / 2 select primes[i];
var weakPrimes = from i in Range(1, primes.Count - 2) where primes[i] < (primes[i-1] + primes[i+1]) / 2.0 select primes[i];
WriteLine($"First 36 strong primes: {string.Join(", ", strongPrimes.Take(36))}");
WriteLine($"There are {strongPrimes.TakeWhile(p => p < 1_000_000).Count():N0} strong primes below {1_000_000:N0}");
Line 167:
There are 37,723 strong primes below 1,000,000
There are 320,991 strong primes below 10,000,000
First 37 weak primes: 3, 7, 13, 19, 23, 31, 43, 47, 61, 73, 83, 89, 103, 109, 113, 131, 139, 151, 167, 181, 193, 199, 229, 233, 241, 271, 283, 293, 313, 317, 337, 349, 353, 359, 383, 389, 401, 409
There are 37,779780 strongweak primes below 1,000,000
There are 321,749750 strongweak primes below 1,000,000</pre>
 
=={{header|Factor}}==
Anonymous user