Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 95ef264

Browse files
add solution for 1134
1 parent 1bbe09c commit 95ef264

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/java/com/fishercoder/solutions/_1134.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@
2424
public class _1134 {
2525
public static class Solution1 {
2626
public boolean isArmstrong(int N) {
27-
return false;
27+
int numOfDigits = 0;
28+
int copyN = N;
29+
while (copyN > 0) {
30+
copyN /= 10;
31+
numOfDigits++;
32+
}
33+
int sum = 0;
34+
copyN = N;
35+
while (N > 0) {
36+
int digit = N % 10;
37+
sum += Math.pow(digit, numOfDigits);
38+
N /= 10;
39+
}
40+
return sum == copyN;
2841
}
2942
}
3043
}

0 commit comments

Comments
 (0)