Ejemplo n.º 1
0
        public int Run()
        {
            var e       = new InfiniteNumberEnumerator();
            var fHelper = new FactorsHelper();

            var flag   = false;
            var found  = 0;
            var result = 0;

            foreach (var n in e)
            {
                flag = fHelper.Factors(n).Count(PrimeCalculator.IsPrime) >= _count;
                if (flag)
                {
                    found++;
                }
                else
                {
                    found = 0;
                }
                if (found == _consec)
                {
                    result = n - _consec + 1;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void fidns_factors_for_100()
        {
            var helper   = new FactorsHelper();
            var result   = helper.Factors(100);
            var expected = new[] { 2, 4, 5, 10, 20, 25, 50 };

            Assert.IsTrue(result.All(r => expected.Contains(r)));
            Assert.IsFalse(result.Any(r => !expected.Contains(r)));
        }