예제 #1
0
        public void CalculateSmallestMultiple()
        {
            var    autod  = new AutoDictionary <double>();
            double result = 1;

            // for the sequence from 1-to-Input, get prime factors for each and store new ones (or higher powers)
            // Then get all factors and multiply them

            // Back then I didn't know IEnumerable.Range o.o
            NumericSources.YieldSequenceFromTo(1, Input).ForEach(x => autod.RegisterIfNew(x.GetPrimeFactors()));
            autod.Dictionary.ForEach(x => result *= Math.Pow(x.Key, x.Value));

            this.SmallestMultiple = result;
        }