MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / Armstrong

Class Armstrong

Java/Armstrong.java:3–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 */
3public 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected