Example #1
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            MyMathClass mathClass = new MyMathClass();

            long sumOfPrimes = mathClass.GetSumOfPrimesUpTo(TARGET);

            stopwatch.Stop();

            Console.WriteLine("Sum of primes below " + TARGET.ToString() + " is " + sumOfPrimes.ToString());
            Console.WriteLine("Elapsed time is: " + stopwatch.ElapsedMilliseconds + " milliseconds");

            Console.ReadKey();
        }
Example #2
0
 public void GetSumOfPrimesUpToTest()
 {
     MyMathClass target = new MyMathClass();
     long number = 2000000;
     long expected = 142913828922;
     long actual;
     actual = target.GetSumOfPrimesUpTo(number);
     Assert.AreEqual(expected, actual);
 }