Skip to content

Commit 887fa0b

Browse files
committed
➕ Armstring
1 parent 7185aad commit 887fa0b

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

Maths/Armstrong/Armstrong.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class AverageList {
2+
public static void main(String[] args) {
3+
System.out.println(isArmStrong(370));
4+
}
5+
6+
private static boolean isArmStrong(int n) {
7+
int temp = n;
8+
int rem = 0;
9+
int sum = 0;
10+
System.out.println(temp);
11+
12+
while (n != 0) {
13+
rem = n % 10;
14+
sum += rem * rem * rem;
15+
n = n / 10;
16+
}
17+
18+
return sum == temp;
19+
}
20+
}

Maths/Armstrong/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Armstrong
2+
3+
**What is Armstrong?**
4+
5+
An armstrong number is a number which equal to the sum of the cubes of its individual digits.
6+
7+
**Explanation**
8+
9+
`370` is an Armstrong number because `3*3*3 + 7*7*7 + 0*0*0 = 370`.
10+
11+
**Example**
12+
13+
Write a function to checks whether a given number is an armstrong number or not.
14+
15+
**Java**
16+
17+
```js
18+
public class AverageList {
19+
public static void main(String[] args) {
20+
System.out.println(isArmStrong(370));
21+
}
22+
23+
private static boolean isArmStrong(int n) {
24+
int temp = n;
25+
int rem = 0;
26+
int sum = 0;
27+
System.out.println(temp);
28+
29+
while (n != 0) {
30+
rem = n % 10;
31+
sum += rem * rem * rem;
32+
n = n / 10;
33+
}
34+
35+
return sum == temp;
36+
}
37+
}
38+
```

Strings/AllCharactersSame/AllCharactersSame.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
public class AllCharactersSame {
2-
32
public static void main(String[] args) {
43
System.out.println(isAllCharactersSame(""));
54
System.out.println(!isAllCharactersSame("aab"));

0 commit comments

Comments
 (0)