Пример #1
0
        static void Main(string[] args)
        {
            DisplayScreen pb6display = new DisplayScreen();

            pb6display.ProblemTitle  = "Problem 5";
            pb6display.ProblemHeader = "Sum square difference";
            pb6display.Description   = "The sum of the squares of the first ten natural numbers is,\n12 + 22 + ... + 102 = 385\nThe square of the sum of the first ten natural numbers is,\n(1 + 2 + ... + 10)2 = 552 = 3025\nHence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.\nFind the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.";
            pb6display.DisplayHeader();

            //////////////////////////////////////////////////////////////////

            long a, b, result;

            a = SumSquareDifference.SumSquares(100);
            b = SumSquareDifference.SquareOfSum(100);

            result = SumSquareDifference.Difference(b, a);
            //Console.WriteLine(result);


            pb6display.DisplayAnswer("difference is :", result);



            pb6display.DisplayFooter();
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            DisplayScreen pb4display = new DisplayScreen();

            pb4display.ProblemTitle  = "Problem 4";
            pb4display.ProblemHeader = "Largest palindrome product";
            pb4display.Description   = "A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.\nFind the largest palindrome made from the product of two 3 - digit numbers.";
            pb4display.DisplayHeader();



            int biggestPalindrome = 0;

            for (int i = 100; i < 1000; i++)
            {
                for (int j = 100; j < 1000; j++)
                {
                    int result = NumberProduct.Product2Numbers(i, j);
                    if (Palindrome.IsPalindrome(result) && result > biggestPalindrome)
                    {
                        biggestPalindrome = result;
                    }
                }
            }

            pb4display.DisplayAnswer("Biggest Palindrome is :", biggestPalindrome);



            pb4display.DisplayFooter();
            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            DisplayScreen pb1display = new DisplayScreen();

            pb1display.ProblemTitle  = "Problem 1";
            pb1display.ProblemHeader = "Multiples of 3 and 5";
            pb1display.Description   = "If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.";
            pb1display.DisplayHeader();

            int s = Multiples.SumOfMultiples(3, 5, 1000);

            pb1display.DisplayAnswer("the total sum of multiples is", s);


            Console.ReadKey();
        }
Пример #4
0
        static void Main(string[] args)
        {
            DisplayScreen pb2display = new DisplayScreen();

            pb2display.ProblemTitle  = "Problem 2";
            pb2display.ProblemHeader = "Even Fibonacci numbers";
            pb2display.Description   = "Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:\n 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... \n By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.";
            pb2display.DisplayHeader();


            int limit = 4000000;
            int total = Fibonacci.SumEvenTerms(limit);



            //Console.WriteLine("Fibonaaci sum for term " + term + " is " + a);
            pb2display.DisplayAnswer("Fibonacci sum for even numbers under 4000000 is : ", total);

            Console.ReadKey();
        }
Пример #5
0
        static void Main(string[] args)
        {
            DisplayScreen pb7display = new DisplayScreen();

            pb7display.ProblemTitle  = "Problem 7";
            pb7display.ProblemHeader = "10001st prime";
            pb7display.Description   = "By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.\nWhat is the 10 001st prime number ? ";
            pb7display.DisplayHeader();

            //////////////////////////////////////////////////////////////////

            int order = 10001;

            int result = PrimeNumberOrder.PrimeNumberST(order);

            pb7display.DisplayAnswer("Prime number " + order + " is  :", result);


            pb7display.DisplayFooter();
            Console.ReadKey();
        }