Tuesday, December 19, 2017

problem 6

 /*
        The sum of the squares of the first ten natural numbers is,

        385
        The square of the sum of the first ten natural numbers is,

        3025
        Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.

        Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
     */
    class Program
    {
        static void Main(string[] args)
        {
            System.Numerics.BigInteger sumOfSquares = 0;
            for (System.Numerics.BigInteger i = 1; i <= 100; i++)
            {
                sumOfSquares += (i * i);
            }

            System.Numerics.BigInteger sums = 0;
            for (int i = 1; i <= 100; i++)
            {
                sums = sums + i;
            }
            System.Numerics.BigInteger squareOfSums = sums * sums;

            Console.WriteLine(squareOfSums - sumOfSquares );
        }

    }

1 comment:

  1. The merit casino: all the slots, roulette, baccarat
    The merit 샌즈카지노 casino: all the slots, roulette, baccarat, dice and roulette. งานออนไลน์ Slot machine 메리트 카지노 games include slot machines, bingo, blackjack, craps,

    ReplyDelete