Skip to content

Commit 8b40781

Browse files
Merge pull request #210 from Sanjay-S17/patch-3
Create Armstrong.java
2 parents c83c54b + 2edd293 commit 8b40781

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Java/Armstrong.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* Armstrong number is a three digit number whose sum of cube of each digit is equal to the number
2+
* Example 153 = 1^3 + 5^3 + 3^3 = 153 */
3+
public class Armstrong {
4+
static boolean Arms(int n){
5+
int org=n;
6+
int ans = 0;
7+
while(n>0){
8+
int rem=n%10;
9+
10+
ans+=rem*rem*rem;
11+
n/=10;
12+
}
13+
return org==ans;
14+
15+
}
16+
public static void main(String[] args) {
17+
18+
for (int i=100;i<1000;i++){
19+
if (Arms(i)){
20+
System.out.print(i+" ");
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)