zoukankan      html  css  js  c++  java
  • 【Project Euler】6 第六题

    

    //The sum of the squares of the first ten natural numbers is,
            //12 + 22 + ... + 102 = 385
            //The square of the sum of the first ten natural numbers is,
            //(1 + 2 + ... + 10)2 = 552 = 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.
           

    static void Main(string[] args)
            {
                int num1 = 0;
                int num2 = 0;
                int num3 = 0;
                int num4 = 0;
                for (int i = 1; i < 101; i++)
                {
                    num1 += i * i;
                    num2 += i;

                }
                num3 = num2 * num2;
                num4 = num3 - num1;
                Console.WriteLine(num1);
                Console.WriteLine(num3);
                Console.WriteLine(num4);
            }

    版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

  • 相关阅读:
    第三章读书笔记
    第二章读书笔记
    第一章读书笔记
    第四章读书笔记
    《android深入探索》第一章心得
    C语言I博客作业04
    C语言I博客作业03
    C语言I博客作业02
    C语言I博客作业4
    C语言博客作业3
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786196.html
Copyright © 2011-2022 走看看