Problem 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.


	//求平方和 
public long squares_sum(int number){
long result = 0;

for(int i=1; i<=number; i++){
result += i*i;
}
return result;
}
//求和的平方
public long sum_squares(int number){
long result = (number*(number+1))/2;
return result*result;
}

public long count(int number){
return sum_squares(number)-squares_sum(number);
}

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Your lock file does not contain a compatible set of packages. Please run composer update. Problem 1 - Root composer.json requires PHP extension ext-redis * but it is missing from your system. Install or enable PHP's redis extension. Problem 2 - endroid/qrcode is locked to version 3.6.0 and an update of this package was not requested. - endroid/qrcode 3.6.0 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. Problem 3 - fastknife/ajcaptcha is locked to version v1.1.5 and an update of this package was not requested. - fastknife/ajcaptcha v1.1.5 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. Problem 4 - intervention/image is locked to version 2.7.2 and an update of this package was not requested. - intervention/image 2.7.2 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. Problem 5 - league/flysystem is locked to version 1.0.69 and an update of this package was not requested. - league/flysystem 1.0.69 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. Problem 6 - mpdf/mpdf is locked to version v8.0.6 and an update of this package was not requested. - mpdf/mpdf v8.0.6 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. Problem 7 - overtrue/wechat is locked to version 4.2.20 and an update of this package was not requested. - overtrue/wechat 4.2.20 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. Problem 8 - setasign/fpdf is locked to version 1.8.4 and an update of this package was not requested. - setasign/fpdf 1.8.4 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. Problem 9 - simplesoftwareio/simple-qrcode is locked to version 4.2.0 and an update of this package was not requested. - simplesoftwareio/simple-qrcode 4.2.0 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. Problem 10 - symfony/translation is locked to version v6.0.0 and an update of this package was not requested. - symfony/translation v6.0.0 requires php >=8.0.2 -> your php version (7.4.0) does not satisfy that requirement. Problem 11 - symfony/translation-contracts is locked to version v3.0.0 and an update of this package was not requested. - symfony/translation-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.4.0) does not satisfy that requirement. Problem 12 - cache/filesystem-adapter is locked to version 1.0.0 and an update of this package was not requested. - cache/filesystem-adapter 1.0.0 requires league/flysystem ^1.0 -> satisfiable by league/flysystem[1.0.69]. - league/flysystem 1.0.69 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. To enable extensions, verify that they are enabled in your .ini files: - E:\software\php\php.ini You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode. Alternatively, you can run Composer with `--ignore-platform-req=ext-redis --ignore-platform-req=ext-gd --ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.
最新发布
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值