public void TestForExample() { byte[] expectedPrimes = new byte[] { 2, 3, 5, 7, 11, 13 }; List <long> primes = new List <long>(); foreach (long prime in Primes.GetPrimeNumber()) { primes.Add(prime); if (primes.Count == 6) { break; } } Assert.AreEqual(expectedPrimes, primes); }
public override long Solution() { long result = 0; int counter = 0; foreach (long primeNumber in Primes.GetPrimeNumber()) { counter++; if (counter == 10001) { result = primeNumber; break; } } return(result); }
static void Main(string[] args) { Console.WriteLine("start"); Primes p = new Primes(N); p.ShowAllPrimes(totalOnly: true); int p10001 = p.GetPrimeNumber(10001 - 1); Console.WriteLine("p10001 = {0}", p10001); //p.TestMergeExpansion(345, 5436); //p.TestSqrExpansion(345); p.DoSpecialExpansion(123, 456, N); // for (int i=110000000-90; i<110000001; i++) // p.ShowExpansion(i); long res = p.GetSumOfPrimesNoMoreThan(2000000); Console.WriteLine("sum of 2k primes: {0}", res); Console.WriteLine(" < -- press any key -- >"); Console.ReadLine(); }