コード例 #1
0
        public void find_largest_prime_factor_of_600851475143()
        {
            var instance         = new Problem003();
            var startingQuotient = 600851475143;
            var result           = instance.GetLargestPrimeDivisor(startingQuotient);

            Assert.AreEqual(6857, result);
        }
コード例 #2
0
        public void output_largest_prime_divisor()
        {
            var instance         = new Problem003();
            var startingQuotient = 30;
            var result           = instance.GetLargestPrimeDivisor(startingQuotient);

            Assert.AreEqual(5, result);
        }
コード例 #3
0
        public void Problem003()
        {
            var problem = new Problem003()
            {
                ConsoleOutput = false, DetailedOutput = false
            };

            Assert.AreEqual(6857L, problem.Answer());
        }
コード例 #4
0
        public void Problem003_Barbecue_Skewers_Test_6()
        {
            string[] bbq = new string[] { };

            int[] act      = Problem003.BarbecueSkewers(bbq);
            int[] excepted = new int[] { 0, 0 };

            Assert.Equal(act, excepted);
        }
コード例 #5
0
        public static void Main(string[] args)
        {
            var stopWatch = Stopwatch.StartNew();

            Problem003 problem = new Problem003();

            Console.WriteLine("{0}", problem.Solution());
            Console.WriteLine("Execution of program took {0} milliseconds to execute", stopWatch.ElapsedMilliseconds);
            Console.ReadLine();
        }
コード例 #6
0
        public void check_if_number_is_not_divisible_by_another_number()
        {
            var instance = new Problem003();
            var divisor  = Any.NumberDivisibleByTwo();
            var dividend = Any.NumberDivisibleByTwo() * divisor + 1;

            var isDivisible = instance.IsDivisibleBy(dividend, divisor);

            Assert.IsFalse(isDivisible);
        }
コード例 #7
0
ファイル: Problem003Tests.cs プロジェクト: yusjoel/Algorithms
        public void SolveTest()
        {
            var list = new List <int>
            {
                1, -2, 3, 10, -4, 7, 2, -5
            };

            int max = Problem003.Solve(list);

            Assert.AreEqual(18, max);
        }
コード例 #8
0
        public void return_quotient_of_two_numbers()
        {
            var instance = new Problem003();
            var divisor  = Any.Number();
            var dividend = Any.Number() * divisor;

            instance.RunningQuotient = dividend;
            var expectedQuotient = dividend / divisor;

            instance.FindQuotientofDividend(divisor);

            Assert.AreEqual(expectedQuotient, instance.RunningQuotient);
        }
コード例 #9
0
        public void Problem003_Barbecue_Skewers_Test_1()
        {
            string[] bbq = new string[] {
                "--oooo-ooo--",
                "--xx--x--xx--",
                "--o---o--oo--",
                "--xx--x--ox--",
                "--xx--x--ox--"
            };

            int[] act      = Problem003.BarbecueSkewers(bbq);
            int[] excepted = new int[] { 2, 3 };

            Assert.Equal(act, excepted);
        }
コード例 #10
0
        public void Problem003_Barbecue_Skewers_Test_4()
        {
            string[] bbq = new string[] {
                "--xxxxx-xx--",
                "--x--x--x-",
                "--x---",
                "-x-----x---x--",
                "--x---x-----x-",
                "--x---x-----x-",
            };

            int[] act      = Problem003.BarbecueSkewers(bbq);
            int[] excepted = new int[] { 0, 6 };

            Assert.Equal(act, excepted);
        }
コード例 #11
0
        // Returns the n-th prime value, where the 1st prime is 2
        public static int NthPrime(int n)
        {
            if (n <= 1)
            {
                return(2);
            }

            int currN     = 2;
            int currPrime = 3;

            while (currN < n)
            {
                currPrime += 2; // Even numbers can't be prime
                if (Problem003.IsPrime((ulong)currPrime))
                {
                    currN++;
                }
            }

            return(currPrime);
        }
コード例 #12
0
ファイル: TestCSharp.cs プロジェクト: ajdust/euler
        public void IsCorrectProblem003()
        {
            var problem = new Problem003();

            Assert.Equal(Answers["3"], problem.Solve());
        }
コード例 #13
0
 public Problem003Test()
 {
     problem003 = new Problem003();
 }