欧拉项目第六题 Sum square difference
2016-03-09 16:13
417 查看
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.
求(1+2+...+100)^2 - (1^2 + 2^2 + ... + 100^2)的值
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.
求(1+2+...+100)^2 - (1^2 + 2^2 + ... + 100^2)的值
public static void main(String[] args) { int total = 0; int end = 100; for(int i=1;i<=end;i++){ for(int j=1;j<=end;j++) { if(i!=j) total+=i*j; } } System.out.println(total); }
相关文章推荐
- 关于JQuery 中$.ajax函数利用jsonp实现Ajax跨域请求ASP.NET的WebService成功获取数据的案例
- ArcGis 创建 FeatureClass
- To remove HTML markup, use BeautifulSoup's get_text() function解决方案
- CSS 布局
- CSS - 针对不同浏览器的写法
- psync scheduled to be closed ASAP for overcoming of output buffer limits
- webstorm+nodejs+JetBrains IDE Support+chrome打造前端开发神器
- 总结的JS数据类型判定(非常全面)
- css3实现背景切换
- jquery checkbox 全选 全不选 反选
- 读书笔记---HTML5实战 MARCO CASARIO(后六章)
- css3技巧——产品列表之鼠标滑过效果(一)
- WebPack系列教程(八):DEV TOOLS
- CreateFeature
- HTML5:多文件上传 Upload multiple files at once with HTML5, jQuery and PHP
- jQuery全屏滚动插件fullPage.js
- javascript中callee与caller的用法和应用场景
- JS第11天
- AngularJs优化小记
- html5 canvas画进度条