Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
22 lines (16 loc) · 535 Bytes

File metadata and controls

22 lines (16 loc) · 535 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package chapter3;
/**
* 阿姆斯特朗数
*/
public class Armstrong {
private static boolean satisfyCondition(int val, int hundredPos, int tenPos, int digitPos) {
return val == (Math.pow(hundredPos, 3) + Math.pow(tenPos, 3) + Math.pow(digitPos, 3));
}
public static void main(String[] args) {
for (int start = 100; start < 1000; start++) {
if (satisfyCondition(start, start/100, (start%100) / 10, start %10)) {
System.out.println(start);
}
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.