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

  • 相关阅读:
    xhEditor struts2实现图片上传
    xhEditor入门基础
    jQuery全屏插件Textarea Fullscreen
    jQuery幻灯片插件Skippr
    jQuery跳房子插件hopscotch
    合理配置SQLSERVER内存
    浅谈SQL Server 对于内存的管理
    SQL Server 临时表和表变量系列之选择篇
    SQLTest系列之INSERT语句测试
    转:表变量与临时表的优缺点
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786196.html
Copyright © 2020-2023  润新知