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柯于旺 原创文章,如需转载请联系本人。

  • 相关阅读:
    判断是否是微信浏览器
    弹性盒模型
    一个发光的搜索边框(纯CSS3)
    小练习
    js控制div是否显示
    遮罩弹窗
    布局
    CSS构造表单
    CSS 滤镜(IE浏览器专属其他浏览器不支持)
    Css中光标,DHTML,缩放的使用
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786196.html
Copyright © 2011-2022 走看看