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

  • 相关阅读:
    MTU 理解和遇到的一些问题
    tm使用
    C++字符串中转义符
    安卓系统修改host文件简单教程
    公有继承的一个理解
    模板打印函数
    linux 设置时区
    ACE中的inline
    SecureCRT中脚本进行交互,发送Ctrl+C
    C++中多态的实现原理
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786196.html
Copyright © 2011-2022 走看看