当前位置:网站首页>Due to 3 ²+ four ²= five ², Therefore, we call '3,4,5' as the number of Pythagorean shares, and find the array of all Pythagorean shares within n (including n).
Due to 3 ²+ four ²= five ², Therefore, we call '3,4,5' as the number of Pythagorean shares, and find the array of all Pythagorean shares within n (including n).
2022-04-23 03:05:00 【Roc-xb】
because 3²+4²=5², So it's called '3,4,5' Is the number of shares , seek n( Include n) Array of all Pythagorean numbers within .
such as :10 Within the Pythagorean array :['3,4,5','6,7,8']
Catalog
One 、 Topic analysis
We've all learned Pythagorean theorem , Know that Pythagorean theorem needs to meet a²+b²=c², We can split the two sides of the equation , First
Traverse once 1~n, Storage c Square result set of , And then through the double layer for Cycle calculation a²+b², Finally, judge a²+b² Are and in c In the square result set of , If in , Just explain ,a,b,c Satisfy the Pythagorean number relationship .
Two 、 Program code
package com;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
int n = 10;
List<Integer> zList = new ArrayList<>();
for (int i = 1; i <= n; i++) {
zList.add(i * i);
}
List<String> result = new ArrayList<>();
for (int x = 1; x < n; x++) {
for (int y = x; y < n; y++) {
int z = x * x + y * y;
if (zList.contains(z)) {
result.add(String.format("'%d,%d,%d'", x, y, (int) Math.sqrt(z)));
}
}
}
System.out.println(result);
}
}
3、 ... and 、 Running results

版权声明
本文为[Roc-xb]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230302132059.html
边栏推荐
- Plug in for vscode
- TP5 multi conditional where query (using PHP variables)
- JS relearning
- Development notes of raspberry pie (12): start Advantech industrial control raspberry pie uno-220 Kit (I): introduction and operation of the system
- Xamarin效果第二十一篇之GIS中可扩展浮动操作按钮
- Redis Cluster集群,主节点故障,主从切换后ip变化,客户端需要处理不
- 一套关于 内存对齐 的C#面试题,做错的人很多!
- Wepy learning record
- Er and eer models
- Redis data server / database / cache (2022)
猜你喜欢

Recursion - outputs continuously increasing numbers
![How to use C language to realize [guessing numbers game]](/img/8c/052dcb0ce64ee1713bebb1340248e6.png)
How to use C language to realize [guessing numbers game]

Cloud computing learning 1 - openstack cloud computing installation and deployment steps with pictures and texts (Xiandian 2.2)

Laravel8- use JWT

HLS / chisel practice CORDIC high performance computing complex square root

.NET点滴:说说Middleware构造中获取不到Scoped服务的问题

基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客?

Detailed explanation of distributed things

Laravel new route file

Blazor University (12)组件 — 组件生命周期
随机推荐
C#中元组对象Tuple的使用
Openfeign details show
Chapter IV project cost management of information system project manager summary
C# WPF UI框架MahApps切换主题
7-11 重排链表 (25 分)
树莓派开发笔记(十二):入手研华ADVANTECH工控树莓派UNO-220套件(一):介绍和运行系统
tf. keras. layers. Embedding function
【新版发布】ComponentOne 新增 .NET 6 和 Blazor 平台控件支持
How to deploy a website with only a server and no domain name?
Wepy learning record
Tips in MATLAB
Creating wechat voucher process with PHP
[Euler plan question 13] sum of large numbers
Regular object type conversion tool - Common DOM class
Recursion - outputs continuously increasing numbers
腾讯视频涨价:一年多赚74亿!关注我领取腾讯VIP会员,周卡低至7元
C# 读写二进制文件
Xamarin效果第二十一篇之GIS中可扩展浮动操作按钮
The difference between encodeuri and encodeuricomponent
Basic SQL (VIII) data update operation practice