Пример #1
0
        public void Problem3Test()
        {
            var         p3  = new Problem3();
            List <long> res = p3.FindPrimes(13195 / 2);

            res = p3.FindFactors(res, 13195);
            var largestPrimeFactor = res[res.Count - 1];

            Assert.AreEqual(largestPrimeFactor, 29);

            //heuristics - 600851475143/2 is even hence 300425737572 non-prime
            //sqrt ()= 775146
            //var val = BigInteger.Pow (600851475143, 1/2).ToString((type)BigInteger);
            res = p3.FindPrimes(775147);
            res = p3.FindFactors(res, 600851475143);
            largestPrimeFactor = res[res.Count - 1];
            Assert.AreEqual(largestPrimeFactor, 6857);
        }