Exemple #1
0
        public void ShouldReturnTheLargestPrimeFactor()
        {
            //Given
            var getFactorsMockResult = new List <int>();

            _factorsRetreiverMock.Setup(x => x.GetFactors(It.IsAny <int>())).Returns(getFactorsMockResult);

            var getPrimeFactorsMockResult = new List <int>
            {
                5, 7, 13, 29
            };

            _primeFactorsRetrieverMock.Setup(x => x.GetPrimeFactors(It.IsAny <List <int> >()))
            .Returns(getPrimeFactorsMockResult);

            var sut = new LargestPrimeFactor(_factorsRetreiverMock.Object, _primeFactorsRetrieverMock.Object);

            //When
            var result = sut.GetLargestPrimeFactor(13195);

            //Then
            const int expectedHighestPrimeFactor = 29;

            Assert.Equal(expectedHighestPrimeFactor, result);
        }
Exemple #2
0
        public void GivenANumber_ReturnsCorrectLargestPrimeFactor(long number, long expectedLargestPrimeFactor)
        {
            // arrange
            var sut = new LargestPrimeFactor();

            // act
            var largestPrimeFactor = sut.Find(number);

            // assert
            Assert.Equal(expectedLargestPrimeFactor, largestPrimeFactor);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Practice.FizzBuzz.Run();    //  Classic FizzBuzz
            Mulitples.Run();            //  Project Euler # 1: Sum of all multiples of 3 and 5 below 1000
            Fib.Run();                  //  Project Euler # 2: Sum of even numbers in Fibonacci sequence below 4000000
            LargestPrimeFactor.Run();   //  Project Euler # 3: Largest prime factor
            Palindrome.Run();           //  Project Euler # 4: Largest palindrome product
            SumSquare.Run();            //  Project Euler # 6: Sum of squares, squares of sums


            System.Console.ReadLine();
        }
Exemple #4
0
        public void TestMethod2()
        {
            //Arrange
            var n        = 600851475143;
            var expected = 6857;

            //Act
            var res = LargestPrimeFactor.Solve(n);

            //Assert
            Assert.AreEqual(expected, res);
        }
Exemple #5
0
        public void TestMethod1()
        {
            //Arrange
            var n        = 100;
            var expected = 5;

            //Act
            var res = LargestPrimeFactor.Solve(n);

            //Assert
            Assert.AreEqual(expected, res);
        }
Exemple #6
0
        public void ShouldReturn29AsTheHighestPrimeFactorOf13195()
        {
            //Given
            var factorsRetreiver      = new FactorsRetreiver();
            var primeFactorsRetreiver = new PrimeFactorsRetriever();

            var sut = new LargestPrimeFactor(factorsRetreiver, primeFactorsRetreiver);

            //When
            var result = sut.GetLargestPrimeFactor(13195);

            //Then
            const int expectedHightPrimeFactor = 29;

            Assert.Equal(expectedHightPrimeFactor, result);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            StringBuilder description = new StringBuilder("Project Euler");

            description.AppendLine("Project Euler provides a large collection of challenges in the domain of computer science and mathematics.");
            description.AppendLine("The challenges typically involve writing a small program to figure out the solution");
            description.AppendLine("to a clever mathematical formula or equation, such as finding the sum of digits");
            description.AppendLine("of all numbers preceding each number in a series.\n");
            description.AppendLine("Bellow is a list of the problems to pick from to get a solution for\n");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(description);

            int id = -1;

            foreach (var value in Enum.GetValues(typeof(EulerProblems)))
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write((int)value + ": " + value + "\n");
                id = (int)value;
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("\nType in a number to get Problems answers.\n");
            var input = Console.ReadKey();

            Console.WriteLine();

            // stops wrong inputs
            int number = 0;

            while (!Int32.TryParse(input.KeyChar.ToString(), out number) || (number > id || number == 0))
            {
                Console.Write("\nPick a number from the list of problems.\n");
                input = Console.ReadKey();
            }


            // Get a enum value to check agaisnt list
            if (Enum.IsDefined(typeof(EulerProblems), number))
            {
                var problem = (EulerProblems)number;
                Console.Clear();

                switch (problem)
                {
                case EulerProblems.MultiplesOf3And5:
                    MultiplesOf3And5.SolveMultiples();
                    break;

                case EulerProblems.EvenFibonacciNumbers:
                    EvenFibonacciNumbers.SolveEvenFibonacci();
                    break;

                case EulerProblems.LargestPrimeFactor:
                    LargestPrimeFactor.ComputeLargestPrime();
                    break;

                case EulerProblems.LargestPalindromeProduct:
                    LargestPalindromeProduct.GetLargestPalindrome();
                    break;
                }
            }

            // pause at the end
            Console.Read();
        }
Exemple #8
0
        public static void Main()
        {
            LargestPrimeFactor largestPrimeFactor = new LargestPrimeFactor();
            //largestPrimeFactor.lar
            //MultiDimentionalArray multiDimentionalArray = new MultiDimentionalArray();
            //multiDimentionalArray.Array2D();

            //JaggedArrays jaggedArrays = new JaggedArrays();
            //jaggedArrays.JaggedArrayExample2D();

            MatrixInSpiralOrder matrixInSpiralOrder = new MatrixInSpiralOrder();

            matrixInSpiralOrder.PrintMatrixInSprialOrder();
            SwitchConsoleStatements();

            int[] arr;

            // Get input selected for class to execute.
            int.TryParse(Console.ReadLine(), out int n);

            switch (n)
            {
            case 0:
                Console.WriteLine("Please insert 5 integers with space separated.");

                // Min max sum
                arr = ArrayInput();
                MiniMaxSum miniMaxSum = new MiniMaxSum();
                miniMaxSum.MiniMaxsum(arr);
                Console.Read();
                break;

            case 1:
                Console.WriteLine("Please insert age of your niece");
                int arCount = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Please insert height of candle with space separated as age.");
                arr = ArrayInput();

                BirthdayCackeCandles birthdayCackeCandles = new BirthdayCackeCandles();
                birthdayCackeCandles.BirthdayCakeCandles(arr);
                Console.Read();
                break;

            case 2:
                Console.WriteLine("Insert time conversion string ex: 12:05:05PM");
                string         timeString     = Console.ReadLine();
                TimeConversion timeConversion = new TimeConversion();
                string         convertedTime  = timeConversion.TimeConversions(timeString);
                Console.WriteLine(convertedTime);
                Console.ReadLine();
                break;

            case 3:
                // Enter details for string interpolatio in future.

                break;

            default:
                Console.WriteLine("Invalid input");
                Console.ReadLine();
                break;
            }
        }
Exemple #9
0
        static void Main(string[] args)
        {
            #region multiples of 3 and 5
            if (IS_MULTIPLES_3_5)
            {
                Console.WriteLine("Sum of all multiples of 3 or 5 below 1000: ");
                ProblemsDoneByHand pdbh = new ProblemsDoneByHand();
                Console.WriteLine(_closeOut);
                Console.WriteLine(pdbh.Answer1());
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Fibonacci
            if (IS_FIBONACCI_SIMPLE == true)
            {
                Fibonacci f = new Fibonacci();
                Console.WriteLine("Input a desired Fibonnaci number: ");
                string value = Console.ReadLine();
                Console.WriteLine(value + " Fibonnaci number! " + f.FibonacciSimple(Convert.ToInt32(value)));
                if (IS_FIBONACCI_SHOW_TERMS == true)
                {
                    for (int i = 0; i < Convert.ToInt32(value); i++)
                    {
                        Console.WriteLine(f.FibonacciSimple(i));
                    }
                }
                Console.WriteLine(_closeOut);
            }

            if (IS_EVEN_FIBONACCI_NUMBERS == true)
            {
                Fibonacci f = new Fibonacci();
                Console.WriteLine("Input Number of Terms");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                Console.WriteLine(value + "" + f.SumOfEvenFibonacciTerms(Convert.ToInt32(value)));
                Console.WriteLine(_closeOut);
            }

            if (IS_1000Digit_FIBONACCI)
            {
                Stopwatch sw = new Stopwatch();
                Fibonacci f  = new Fibonacci();
                Console.WriteLine("Input Number of Digits");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Index for first {0} digit number: {1}", value, f.FibonacciDigitCount(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region LargestPrime
            if (IS_LARGEST_PRIME_FACTOR_RECURSIVE)
            {
                Stopwatch          sw  = new Stopwatch();
                LargestPrimeFactor lfp = new LargestPrimeFactor();
                Console.WriteLine("Input Number you want the Largest Prime factor of");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Largest Prime factor: " + lfp.LargestPrimeFactorSlow(Convert.ToInt64(value)));
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            if (IS_LARGEST_PRIME_FACTOR_QUICKER)
            {
                Stopwatch          sw  = new Stopwatch();
                LargestPrimeFactor lfp = new LargestPrimeFactor();
                Console.WriteLine("Input Number you want the Largest Prime factor of");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Largest Prime factor: " + lfp.LargestPrimeFactorFaster(Convert.ToInt64(value)));
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Palindrome
            if (IS_PALINDROME_3_DIGITS_RECURSIVE)
            {
                Stopwatch  sw = new Stopwatch();
                Palindrome p  = new Palindrome();
                Console.WriteLine("Calculating largest Palindrome from the product of two 3 digit numbers (recursive):");
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Answer: " + p.LargestPalindromeThreeDigitsRecursive());
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            if (IS_PALINDROME_3_DIGITS_QUICKER)
            {
                Stopwatch  sw = new Stopwatch();
                Palindrome p  = new Palindrome();
                Console.WriteLine("Calculating largest Palindrome from the product of two 3 digit numbers (p builder):");
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Answer: " + p.LargestPalindromeThreeDigitsQuicker());
                Console.WriteLine("Made by multiplying " + p.Factor + " and " + p.Factor1);
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region SmallestMultiple

            if (IS_SMALLEST_MULTIPLE_RANGE_GCD_EUCLIDEAN)
            {
                Stopwatch        sw = new Stopwatch();
                SmallestMultiple sm = new SmallestMultiple();
                Console.WriteLine("Enter Max number for range of Smallest Multiple (starts at 1): ");
                Console.WriteLine(_closeOut);
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Answer: " + sm.SmallestMultipleByRange(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            #endregion

            #region SumSquareDifference
            if (IS_SUM_SQUARE_DIFFERENCE)
            {
                Stopwatch           sw  = new Stopwatch();
                SumSquareDifference ssd = new SumSquareDifference();
                Console.WriteLine("Input Max Natural Number: ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Square of Sums: " + ssd.squareSum(Convert.ToInt32(value)));
                Console.WriteLine("Sum of Square: " + ssd.sumSquare(Convert.ToInt32(value)));
                Console.WriteLine("Sum Square Difference: " + ssd.SumSquareDifferenceAnswer(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            #endregion

            #region 10001st prime
            if (IS_FIND_PRIME_BY_NUMBER)
            {
                Stopwatch sw = new Stopwatch();
                Prime     p  = new Prime();
                Console.WriteLine("Input Desired Prime Number: ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Selected Prime: " + p.GetPrimeAtNumber(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Largest Product in a series
            if (IS_LARGEST_PRODUCT_IN_SERIES)
            {
                Stopwatch            sw  = new Stopwatch();
                Prime                p   = new Prime();
                LargestProductSeries lps = new LargestProductSeries();
                sw.Start();
                Console.WriteLine("Answer 8 for long series: " + lps.Answer8());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Pythagorean Triplet
            if (IS_PYTHAGOREAN_TRIPLET)
            {
                Stopwatch          sw = new Stopwatch();
                Palindrome         p  = new Palindrome();
                PythagoreanTriplet pt = new PythagoreanTriplet();
                Console.WriteLine("Input sum of desired Pythagorean Triplet product:");
                Console.WriteLine(_closeOut);
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Answer: " + pt.Answer9(Convert.ToInt64(value)));
                Console.WriteLine("Values A {0}, B {1}, C {2} ", pt.A, pt.B, pt.C);
                sw.Stop();
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Summation of Primes
            if (IS_SUMMATION_OF_PRIMES)
            {
                Stopwatch sw = new Stopwatch();
                Prime     p  = new Prime();
                Console.WriteLine("Input max number (primes below it will be summed) : ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Sum of Primes: " + p.GetSumOfPrimes(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            #endregion

            #region Largest Product in a grid
            if (IS_LARGEST_PRODUCT_IN_GRID)
            {
                Stopwatch            sw  = new Stopwatch();
                LargestProductSeries lps = new LargestProductSeries();
                sw.Start();
                Console.WriteLine("Answer 11 for product in Grid: " + lps.Answer11());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Highly divisible trangular number
            if (IS_HIGHLY_DIVISIBLE_TRIANGLE_NUMBER)
            {
                Stopwatch        sw = new Stopwatch();
                TriangularNumber tn = new TriangularNumber();
                Console.WriteLine("Input max number (for divisors of triangular number) : ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Number of first triangle with 500 divisors: " + tn.Answer12(Convert.ToInt64(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Large Sum
            if (IS_LARGE_SUM)
            {
                Stopwatch        sw  = new Stopwatch();
                LargestSumSeries lss = new LargestSumSeries();
                Console.WriteLine("Answer 13 coming up! : ");
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("First 10 digits of Sum for Answer 13: " + lss.Answer13());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Longest Collatz sequence
            if (IS_LONGEST_COLLATZ)
            {
                Stopwatch       sw = new Stopwatch();
                CollatzSequence cs = new CollatzSequence();
                Console.WriteLine("Input max number: ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("Starting number: " + cs.CollatzLargestUnderInput(Convert.ToInt64(value)) + " Sequence length: " + cs.SequenceLength);
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region LatticePath
            if (IS_LATTICE_PATH)
            {
                Stopwatch   sw = new Stopwatch();
                LatticePath lp = new LatticePath();
                Console.WriteLine("Input square grid dimensions: ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("For a {0}x{0} grid there are {1} possible paths. ", Convert.ToInt64(value), lp.LatticePathForSpecifiedGrid(Convert.ToInt64(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region PowerDigitSum
            if (IS_POWER_DIGIT_SUM)
            {
                Stopwatch     sw  = new Stopwatch();
                PowerDigitSum pds = new PowerDigitSum();
                Console.WriteLine("Input base number: ");
                string value = Console.ReadLine();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Input power: ");
                string value1 = Console.ReadLine();
                Console.WriteLine(_closeOut);
                sw.Start();
                Console.WriteLine("{0} to the {1} power: ", Convert.ToInt64(value), (Convert.ToInt64(value1)));
                Console.WriteLine("Equals: {0}", pds.Power(Convert.ToInt64(value), Convert.ToInt32(value1)));
                Console.WriteLine(_closeOut);
                Console.WriteLine("Sum of Digits: ");
                Console.WriteLine(pds.BetterSumOfDigits(pds.Power(Convert.ToInt64(value), Convert.ToInt32(value1))));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Number Letter Counts
            if (IS_NUMBER_LETTER_COUNTS)
            {
                ProblemsDoneByHand pdbh = new ProblemsDoneByHand();
                Console.WriteLine("1- 1000 in words total letters (no spaces or hyphens include ands): ");
                Console.WriteLine(_closeOut);
                Console.WriteLine(pdbh.Answer17());
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Maximum path sum
            if (IS_MAX_PATH_SUM)
            {
                Stopwatch      sw  = new Stopwatch();
                MaximumPathSum mps = new MaximumPathSum();
                Console.WriteLine("Maximum Path Sum Problem 18: ");
                sw.Start();
                Console.WriteLine("Answer:  " + mps.Problem18());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Counting Sundays
            if (IS_COUNTING_SUNDAYS)
            {
                Stopwatch          sw  = new Stopwatch();
                DayDateCalculation ddc = new DayDateCalculation();
                Console.WriteLine("Sundays on the first between 1901 - 2000: ");
                sw.Start();
                Console.WriteLine("Answer:  " + ddc.Problem19());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Factorial Digit Sum
            if (IS_FACTORIAL_DIGIT_SUM)
            {
                Stopwatch    sw = new Stopwatch();
                FactorialSum fs = new FactorialSum();
                Console.WriteLine("Enter Factorial digit sum: ");
                string value = Console.ReadLine();
                sw.Start();
                Console.WriteLine("Answer:  " + fs.FactorialDigitSum(Convert.ToInt64(value)));
                Console.WriteLine(_closeOut);
                Console.WriteLine("Number:  " + fs.Factor);
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }

            if (IS_FACTORIAL_SUM)
            {
                Stopwatch    sw = new Stopwatch();
                FactorialSum fs = new FactorialSum();
                Console.WriteLine("Sum of Factorials from digits = number answer 34: ");
                sw.Start();
                Console.WriteLine("The Sum of all numbers who are equal to the sum of their digit's factorials " + fs.SumOfFactorialsIsNumber());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Amicable Numbers
            if (IS_AMICABLE_NUMBERS)
            {
                Stopwatch       sw = new Stopwatch();
                AmicableNumbers an = new AmicableNumbers();
                Console.WriteLine("Enter max number for amicable numbers: ");
                string value = Console.ReadLine();
                sw.Start();
                Console.WriteLine("Answer:  " + an.Simple(Convert.ToInt64(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Non-abundant Sums
            if (IS_NON_ABUNDANT_SUMS)
            {
                Stopwatch       sw  = new Stopwatch();
                NonAbundantSums nas = new NonAbundantSums();
                Console.WriteLine("Enter max number for non-abundant sums: ");
                string value = Console.ReadLine();
                sw.Start();
                Console.WriteLine("Answer:  " + nas.Answer23(Convert.ToInt32(value)));
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Lexicographic Permutations
            if (IS_LEXICOGRAPHIC_PERMUTATIONS)
            {
                Stopwatch sw = new Stopwatch();
                LexicographicPermutations lp = new LexicographicPermutations();
                sw.Start();
                Console.WriteLine("Answer 24 Lexicographic Permutation for 1-9: " + lp.Answer24());
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Reciprocal cycles
            if (IS_RECIPROCAL_CYCLES)
            {
                Stopwatch       sw = new Stopwatch();
                ReciprocalCycle rc = new ReciprocalCycle();
                Console.WriteLine("Enter max number for reciprocal cycle (1000): ");
                string value = Console.ReadLine();
                sw.Start();
                Console.WriteLine("The number with the longest recurring cycle is {0}, and the cycle is length {1}", rc.Answer26(Convert.ToInt32(value)), rc.SequenceLength);
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            #region Quadratic Primes
            if (IS_QUADRATIC_PRIMES)
            {
                Stopwatch       sw = new Stopwatch();
                QuadraticPrimes qp = new QuadraticPrimes();
                Console.WriteLine("Quadratic Primes answer 27: ");
                sw.Start();
                Console.WriteLine("A sequence of length {0}, is generated by a = {1}, b = {2}, the product is {3}", qp.Problem27(), qp.AMax, qp.BMax, qp.AMax * qp.BMax);
                sw.Stop();
                Console.WriteLine(_closeOut);
                Console.WriteLine("Duration: " + sw.Elapsed);
                Console.WriteLine(_closeOut);
            }
            #endregion

            Console.ReadLine();
        }
Exemple #10
0
 public void ProjectEulerNumberCheck()
 {
     Assert.That(LargestPrimeFactor.LargestPrimeFactorMehtod(600851475143), Is.EqualTo(6857));
 }
Exemple #11
0
 public void LargestPrimeFactorFound(long num, long expected)
 {
     Assert.That(LargestPrimeFactor.LargestPrimeFactorMehtod(num), Is.EqualTo(expected));
 }
Exemple #12
0
 public void GivenPrimeN_ReturnPrimeN(long num)
 {
     Assert.That(LargestPrimeFactor.LargestPrimeFactorMehtod(num), Is.EqualTo(num));
 }
Exemple #13
0
 public void Given1_Return1()
 {
     Assert.That(LargestPrimeFactor.LargestPrimeFactorMehtod(1), Is.EqualTo(1));
 }
 static void Main(string[] args)
 {
     LargestPrimeFactor.Test();
     Console.ReadKey();
 }
Exemple #15
0
        public void FindLargestPrimeFactor_ShouldWork(long expected, long number)
        {
            long actual = LargestPrimeFactor.BiggestPrimeFactor(number);

            Assert.Equal(expected, actual);
        }
Exemple #16
0
        public void TestLargestPrimeFactor()
        {
            var actual = LargestPrimeFactor.GetLargestPrimeFactor();

            Assert.Equal(6857, actual);
        }